﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GatewayInspect.Common;
using System.Data.OracleClient;
using System.Media;

namespace GatewayInspect.Modules
{
    public partial class FczlModule : BaseModule
    {
        public FczlModule()
        {
            InitializeComponent();
        }
        protected override void OnInitialize()
        {
            base.OnInitialize();
            foreach (ToolStripItem item in this.tsMain.Items)
            {
                if (item != tsBtnRefresh && item != tsBtnClose && item != toolStripSeparator3)
                {
                    item.Visible = false;
                }
            }
        }
        string NUM = "0";
        string NUM1 = "0";
        string NUM2 = "0";
        string NUM4 = "0";
        string NUM5 = "0";
        string NUM6 = "0";
        protected override void OnLoadModule()
        {
            base.OnLoadModule();
            if (Session.CurrentUserRole == "1" && Session.CurrentUserName == "ADMIN")
            {
                //实华黄岛
                string strSql = "select t.PLAN_NO,t.TRUCK_NO,ORDER_TIME,decode(t.IF_END, '0','在场','1','离场') IF_END,decode(t.ORGCODE, '01','实华黄岛','02','实华董家口','03','摩科瑞','21','红星库区','22','天安','23','丽星','24','益佳','25','中油','11','平安停车场1','12','平安停车场2','13','平安停车场3','15','安顺停车场1','16','安顺停车场2','23','金赛物流停车场') ORGNAME,t.IN_PARK_TIME AS IN_DATE from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='01'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL = DataAccess.ExecuteDataTable(strSql);
                if (dtCYJL != null && dtCYJL.Rows.Count > 0)
                {
                    dtCYJL.Columns.Add("DRIVER_TEL", typeof(string));
                    for (int i = 0; i < dtCYJL.Rows.Count; i++)
                    {
                        string TRUCK_NO = dtCYJL.Rows[i]["TRUCK_NO"].ToString();
                        string PLAN_NO = dtCYJL.Rows[i]["PLAN_NO"].ToString();
                        string strSqlTel = "select d.phone as DRIVER_TEL from wlw_dbc_driver d where d.id in (select b.driver_id from wlw_dbc_oil_bill b where b.plan_no= '" + PLAN_NO + "' and head_car_id in (select i.id from wlw_dbc_oilcar_info i where i.car_no= '" + TRUCK_NO + "'))";
                        DataTable dtTel = DataAccess.ExecuteDataTable(strSqlTel);
                        if (dtTel != null && dtTel.Rows.Count > 0)
                        {
                            string DRIVER_TEL = dtTel.Rows[0]["DRIVER_TEL"].ToString();
                            dtCYJL.Rows[i]["DRIVER_TEL"] = DRIVER_TEL;
                        }
                    }
                    
                }
                this.cdgvGZJL.AutoGenerateColumns = false;
                this.cdgvGZJL.DataSource = dtCYJL;

                //进行统计
                string strSqlNum = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='01'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJLNum = DataAccess.ExecuteDataTable(strSqlNum);
                string num = dtCYJLNum.Rows[0]["NUM"].ToString();
                this.label2.Text = num;
                if(num!="0")
                {
                    //平安1车数
                    string strSqlPA1 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='11' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='01'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA1 = DataAccess.ExecuteDataTable(strSqlPA1);
                    string numPA1 = dtCYJLPA1.Rows[0]["NUM"].ToString();

                    //平安2车数
                    string strSqlPA2 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='12' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='01'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA2 = DataAccess.ExecuteDataTable(strSqlPA2);
                    string numPA2 = dtCYJLPA2.Rows[0]["NUM"].ToString();

                    //平安3车数
                    string strSqlPA3 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='13' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='01'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA3 = DataAccess.ExecuteDataTable(strSqlPA3);
                    string numPA3 = dtCYJLPA3.Rows[0]["NUM"].ToString();

                    //安顺1车数
                    string strSqlAS1 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='15' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='01'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLAS1 = DataAccess.ExecuteDataTable(strSqlAS1);
                    string numAS1 = dtCYJLAS1.Rows[0]["NUM"].ToString();

                    //安顺2车数
                    string strSqlAS2 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='16' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='01'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLAS2 = DataAccess.ExecuteDataTable(strSqlAS2);
                    string numAS2 = dtCYJLAS2.Rows[0]["NUM"].ToString();

                    this.label19.Text = "平安1：" + numPA1 + "   平安2：" + numPA2 + "   平安3：" + numPA3 + "   安顺1：" + numAS1 + "   安顺2：" + numAS2;
                } if (num == "0") {
                    this.label19.Text = "";
                }
               
                
                //丽星
                string strSql1 = "select t.PLAN_NO,t.TRUCK_NO,ORDER_TIME,decode(t.IF_END, '0','在场','1','离场') IF_END,decode(t.ORGCODE, '01','实华黄岛','02','实华董家口','03','摩科瑞','21','红星库区','22','天安','23','丽星','24','益佳','25','中油','11','平安停车场1','12','平安停车场2','13','平安停车场3','15','安顺停车场1','16','安顺停车场2','23','金赛物流停车场') ORGNAME,t.IN_PARK_TIME AS IN_DATE from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='23'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL1 = DataAccess.ExecuteDataTable(strSql1);
               
                if (dtCYJL1 != null && dtCYJL1.Rows.Count > 0)
                {
                    dtCYJL1.Columns.Add("DRIVER_TEL", typeof(string));
                    for (int i = 0; i < dtCYJL1.Rows.Count; i++)
                    {
                        string TRUCK_NO = dtCYJL1.Rows[i]["TRUCK_NO"].ToString();
                        string PLAN_NO = dtCYJL1.Rows[i]["PLAN_NO"].ToString();
                        string strSqlTel = "select d.phone as DRIVER_TEL from wlw_dbc_driver d where d.id in (select b.driver_id from wlw_dbc_oil_bill b where b.plan_no= '" + PLAN_NO + "' and head_car_id in (select i.id from wlw_dbc_oilcar_info i where i.car_no= '" + TRUCK_NO + "'))";
                        DataTable dtTel = DataAccess.ExecuteDataTable(strSqlTel);
                        if (dtTel != null && dtTel.Rows.Count > 0)
                        {
                            string DRIVER_TEL = dtTel.Rows[0]["DRIVER_TEL"].ToString();
                            dtCYJL1.Rows[i]["DRIVER_TEL"] = DRIVER_TEL;
                        }
                    }
                   
                }
                this.cDataGridView1.AutoGenerateColumns = false;
                this.cDataGridView1.DataSource = dtCYJL1;
                //进行统计
                string strSql1Num = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='23'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL1Num = DataAccess.ExecuteDataTable(strSql1Num);
                string num1 = dtCYJL1Num.Rows[0]["NUM"].ToString();
                this.label10.Text = num1;

                if (num1 != "0")
                {
                    //平安1车数
                    string strSqlPA1 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='11' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='23'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA1 = DataAccess.ExecuteDataTable(strSqlPA1);
                    string numPA1 = dtCYJLPA1.Rows[0]["NUM"].ToString();

                    //平安2车数
                    string strSqlPA2 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='12' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='23'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA2 = DataAccess.ExecuteDataTable(strSqlPA2);
                    string numPA2 = dtCYJLPA2.Rows[0]["NUM"].ToString();

                    //平安3车数
                    string strSqlPA3 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='13' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='23'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA3 = DataAccess.ExecuteDataTable(strSqlPA3);
                    string numPA3 = dtCYJLPA3.Rows[0]["NUM"].ToString();

                    //安顺1车数
                    string strSqlAS1 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='15' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='23'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLAS1 = DataAccess.ExecuteDataTable(strSqlAS1);
                    string numAS1 = dtCYJLAS1.Rows[0]["NUM"].ToString();

                    //安顺2车数
                    string strSqlAS2 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='16' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='23'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLAS2 = DataAccess.ExecuteDataTable(strSqlAS2);
                    string numAS2 = dtCYJLAS2.Rows[0]["NUM"].ToString();

                    this.label20.Text = "平安1：" + numPA1 + " 平安2：" + numPA2 + " 平安3：" + numPA3 + " 安顺1：" + numAS1 + " 安顺2：" + numAS2;
                } if (num1 == "0")
                {
                    this.label20.Text = "";
                }
                //天安
                string strSql2 = "select t.PLAN_NO,t.TRUCK_NO,ORDER_TIME,decode(t.IF_END, '0','在场','1','离场') IF_END,decode(t.ORGCODE, '01','实华黄岛','02','实华董家口','03','摩科瑞','21','红星库区','22','天安','23','丽星','24','益佳','25','中油','11','平安停车场1','12','平安停车场2','13','平安停车场3','15','安顺停车场1','16','安顺停车场2','23','金赛物流停车场') ORGNAME,t.IN_PARK_TIME AS IN_DATE from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='22' ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL2 = DataAccess.ExecuteDataTable(strSql2);
                if (dtCYJL2 != null && dtCYJL2.Rows.Count > 0)
                {
                    dtCYJL2.Columns.Add("DRIVER_TEL", typeof(string));
                    for (int i = 0; i < dtCYJL2.Rows.Count; i++)
                    {
                        string TRUCK_NO = dtCYJL2.Rows[i]["TRUCK_NO"].ToString();
                        string PLAN_NO = dtCYJL2.Rows[i]["PLAN_NO"].ToString();
                        string strSqlTel = "select d.phone as DRIVER_TEL from wlw_dbc_driver d where d.id in (select b.driver_id from wlw_dbc_oil_bill b where b.plan_no= '" + PLAN_NO + "' and head_car_id in (select i.id from wlw_dbc_oilcar_info i where i.car_no= '" + TRUCK_NO + "'))";
                        DataTable dtTel = DataAccess.ExecuteDataTable(strSqlTel);
                        if (dtTel != null && dtTel.Rows.Count > 0)
                        {
                            string DRIVER_TEL = dtTel.Rows[0]["DRIVER_TEL"].ToString();
                            dtCYJL2.Rows[i]["DRIVER_TEL"] = DRIVER_TEL;
                        }
                    }
                    
                }
                this.cDataGridView2.AutoGenerateColumns = false;
                this.cDataGridView2.DataSource = dtCYJL2;
                //进行统计
                string strSql2Num = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='22'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL2Num = DataAccess.ExecuteDataTable(strSql2Num);
                string num2 = dtCYJL2Num.Rows[0]["NUM"].ToString();
                this.label12.Text = num2;
                if (num2 != "0")
                {
                    //平安1车数
                    string strSqlPA1 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='11' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='22'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA1 = DataAccess.ExecuteDataTable(strSqlPA1);
                    string numPA1 = dtCYJLPA1.Rows[0]["NUM"].ToString();

                    //平安2车数
                    string strSqlPA2 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='12' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='22'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA2 = DataAccess.ExecuteDataTable(strSqlPA2);
                    string numPA2 = dtCYJLPA2.Rows[0]["NUM"].ToString();

                    //平安3车数
                    string strSqlPA3 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='13' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='22'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA3 = DataAccess.ExecuteDataTable(strSqlPA3);
                    string numPA3 = dtCYJLPA3.Rows[0]["NUM"].ToString();

                    //安顺1车数
                    string strSqlAS1 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='15' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='22'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLAS1 = DataAccess.ExecuteDataTable(strSqlAS1);
                    string numAS1 = dtCYJLAS1.Rows[0]["NUM"].ToString();

                    //安顺2车数
                    string strSqlAS2 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='16' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='22'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLAS2 = DataAccess.ExecuteDataTable(strSqlAS2);
                    string numAS2 = dtCYJLAS2.Rows[0]["NUM"].ToString();

                    this.label21.Text = "平安1：" + numPA1 + " 平安2：" + numPA2 + " 平安3：" + numPA3 + " 安顺1：" + numAS1 + " 安顺2：" + numAS2;
                }
                if (num2 == "0")
                {
                    this.label21.Text = "";
                }
                //益佳
                string strSql3 = "select t.PLAN_NO,t.TRUCK_NO,ORDER_TIME,decode(t.IF_END, '0','在场','1','离场') IF_END,decode(t.ORGCODE, '01','实华黄岛','02','实华董家口','03','摩科瑞','21','红星库区','22','天安','23','丽星','24','益佳','25','中油','11','平安停车场1','12','平安停车场2','13','平安停车场3','15','安顺停车场1','16','安顺停车场2','23','金赛物流停车场') ORGNAME,t.IN_PARK_TIME AS IN_DATE from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='24'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL3 = DataAccess.ExecuteDataTable(strSql3);
                if (dtCYJL3 != null && dtCYJL3.Rows.Count > 0)
                {
                    dtCYJL3.Columns.Add("DRIVER_TEL", typeof(string));
                    for (int i = 0; i < dtCYJL3.Rows.Count; i++)
                    {
                        string TRUCK_NO = dtCYJL3.Rows[i]["TRUCK_NO"].ToString();
                        string PLAN_NO = dtCYJL3.Rows[i]["PLAN_NO"].ToString();
                        string strSqlTel = "select d.phone as DRIVER_TEL from wlw_dbc_driver d where d.id in (select b.driver_id from wlw_dbc_oil_bill b where b.plan_no= '" + PLAN_NO + "' and head_car_id in (select i.id from wlw_dbc_oilcar_info i where i.car_no= '" + TRUCK_NO + "'))";
                        DataTable dtTel = DataAccess.ExecuteDataTable(strSqlTel);
                        if (dtTel != null && dtTel.Rows.Count > 0)
                        {
                            string DRIVER_TEL = dtTel.Rows[0]["DRIVER_TEL"].ToString();
                            dtCYJL3.Rows[i]["DRIVER_TEL"] = DRIVER_TEL;
                        }
                    }
                   
                }
                this.cDataGridView3.AutoGenerateColumns = false;
                this.cDataGridView3.DataSource = dtCYJL3;

                //进行统计
                string strSql4Num = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='24'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL4Num = DataAccess.ExecuteDataTable(strSql4Num);
                string num4 = dtCYJL4Num.Rows[0]["NUM"].ToString();
                this.label14.Text = num4;
                if (num4 != "0")
                {
                    //平安1车数
                    string strSqlPA1 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='11' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='24'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA1 = DataAccess.ExecuteDataTable(strSqlPA1);
                    string numPA1 = dtCYJLPA1.Rows[0]["NUM"].ToString();

                    //平安2车数
                    string strSqlPA2 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='12' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='24'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA2 = DataAccess.ExecuteDataTable(strSqlPA2);
                    string numPA2 = dtCYJLPA2.Rows[0]["NUM"].ToString();

                    //平安3车数
                    string strSqlPA3 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='13' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='24'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA3 = DataAccess.ExecuteDataTable(strSqlPA3);
                    string numPA3 = dtCYJLPA3.Rows[0]["NUM"].ToString();

                    //安顺1车数
                    string strSqlAS1 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='15' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='24'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLAS1 = DataAccess.ExecuteDataTable(strSqlAS1);
                    string numAS1 = dtCYJLAS1.Rows[0]["NUM"].ToString();

                    //安顺2车数
                    string strSqlAS2 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='16' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='24'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLAS2 = DataAccess.ExecuteDataTable(strSqlAS2);
                    string numAS2 = dtCYJLAS2.Rows[0]["NUM"].ToString();

                    this.label22.Text = "平安1：" + numPA1 + " 平安2：" + numPA2 + " 平安3：" + numPA3 + " 安顺1：" + numAS1 + " 安顺2：" + numAS2;
                } if (num4 == "0")
                {
                    this.label22.Text = "";
                }
                //中油
                string strSql4 = "select t.PLAN_NO,t.TRUCK_NO,ORDER_TIME,decode(t.IF_END, '0','在场','1','离场') IF_END,decode(t.ORGCODE, '01','实华黄岛','02','实华董家口','03','摩科瑞','21','红星库区','22','天安','23','丽星','24','益佳','25','中油','11','平安停车场1','12','平安停车场2','13','平安停车场3','15','安顺停车场1','16','安顺停车场2','23','金赛物流停车场') ORGNAME,t.IN_PARK_TIME AS IN_DATE from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='25'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL4 = DataAccess.ExecuteDataTable(strSql4);
                if (dtCYJL4 != null && dtCYJL4.Rows.Count > 0)
                {
                    dtCYJL4.Columns.Add("DRIVER_TEL", typeof(string));
                    for (int i = 0; i < dtCYJL4.Rows.Count; i++)
                    {
                        string TRUCK_NO = dtCYJL4.Rows[i]["TRUCK_NO"].ToString();
                        string PLAN_NO = dtCYJL4.Rows[i]["PLAN_NO"].ToString();
                        string strSqlTel = "select d.phone as DRIVER_TEL from wlw_dbc_driver d where d.id in (select b.driver_id from wlw_dbc_oil_bill b where b.plan_no= '" + PLAN_NO + "' and head_car_id in (select i.id from wlw_dbc_oilcar_info i where i.car_no= '" + TRUCK_NO + "'))";
                        DataTable dtTel = DataAccess.ExecuteDataTable(strSqlTel);
                        if (dtTel != null && dtTel.Rows.Count > 0)
                        {
                            string DRIVER_TEL = dtTel.Rows[0]["DRIVER_TEL"].ToString();
                            dtCYJL4.Rows[i]["DRIVER_TEL"] = DRIVER_TEL;
                        }
                    }
                    
                }
                this.cDataGridView4.AutoGenerateColumns = false;
                this.cDataGridView4.DataSource = dtCYJL4;
                //进行统计
                string strSql5Num = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='25'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL5Num = DataAccess.ExecuteDataTable(strSql5Num);
                string num5 = dtCYJL5Num.Rows[0]["NUM"].ToString();
                this.label16.Text = num5;
                if (num5 != "0")
                {
                    //平安1车数
                    string strSqlPA1 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='11' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='25'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA1 = DataAccess.ExecuteDataTable(strSqlPA1);
                    string numPA1 = dtCYJLPA1.Rows[0]["NUM"].ToString();

                    //平安2车数
                    string strSqlPA2 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='12' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='25'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA2 = DataAccess.ExecuteDataTable(strSqlPA2);
                    string numPA2 = dtCYJLPA2.Rows[0]["NUM"].ToString();

                    //平安3车数
                    string strSqlPA3 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='13' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='25'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA3 = DataAccess.ExecuteDataTable(strSqlPA3);
                    string numPA3 = dtCYJLPA3.Rows[0]["NUM"].ToString();

                    //安顺1车数
                    string strSqlAS1 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='15' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='25'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLAS1 = DataAccess.ExecuteDataTable(strSqlAS1);
                    string numAS1 = dtCYJLAS1.Rows[0]["NUM"].ToString();

                    //安顺2车数
                    string strSqlAS2 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='16' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='25'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLAS2 = DataAccess.ExecuteDataTable(strSqlAS2);
                    string numAS2 = dtCYJLAS2.Rows[0]["NUM"].ToString();

                    this.label23.Text = "平安1：" + numPA1 + " 平安2：" + numPA2 + " 平安3：" + numPA3 + " 安顺1：" + numAS1 + " 安顺2：" + numAS2;
                } if (num5 == "0")
                {
                    this.label23.Text = "";
                }

                //红星
                string strSql5 = "select t.PLAN_NO,t.TRUCK_NO,ORDER_TIME,decode(t.IF_END, '0','在场','1','离场') IF_END,decode(t.ORGCODE, '01','实华黄岛','02','实华董家口','03','摩科瑞','21','红星库区','22','天安','23','丽星','24','益佳','25','中油','11','平安停车场1','12','平安停车场2','13','平安停车场3','15','安顺停车场1','16','安顺停车场2','23','金赛物流停车场') ORGNAME,t.IN_PARK_TIME AS IN_DATE from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='21'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL5 = DataAccess.ExecuteDataTable(strSql5);
                if (dtCYJL5 != null && dtCYJL5.Rows.Count > 0)
                {
                    dtCYJL5.Columns.Add("DRIVER_TEL", typeof(string));
                    for (int i = 0; i < dtCYJL5.Rows.Count; i++)
                    {
                        string TRUCK_NO = dtCYJL5.Rows[i]["TRUCK_NO"].ToString();
                        string PLAN_NO = dtCYJL5.Rows[i]["PLAN_NO"].ToString();
                        string strSqlTel = "select d.phone as DRIVER_TEL from wlw_dbc_driver d where d.id in (select b.driver_id from wlw_dbc_oil_bill b where b.plan_no= '" + PLAN_NO + "' and head_car_id in (select i.id from wlw_dbc_oilcar_info i where i.car_no= '" + TRUCK_NO + "'))";
                        DataTable dtTel = DataAccess.ExecuteDataTable(strSqlTel);
                        if (dtTel != null && dtTel.Rows.Count > 0)
                        {
                            string DRIVER_TEL = dtTel.Rows[0]["DRIVER_TEL"].ToString();
                            dtCYJL5.Rows[i]["DRIVER_TEL"] = DRIVER_TEL;
                        }
                    }
                    
                }
                this.cDataGridView5.AutoGenerateColumns = false;
                this.cDataGridView5.DataSource = dtCYJL5;

                //进行统计
                string strSql6Num = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='21'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL6Num = DataAccess.ExecuteDataTable(strSql6Num);
                string num6 = dtCYJL6Num.Rows[0]["NUM"].ToString();
                this.label18.Text = num6;
                if (num6 != "0")
                {
                    //平安1车数
                    string strSqlPA1 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='11' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='21'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA1 = DataAccess.ExecuteDataTable(strSqlPA1);
                    string numPA1 = dtCYJLPA1.Rows[0]["NUM"].ToString();

                    //平安2车数
                    string strSqlPA2 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='12' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='21'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA2 = DataAccess.ExecuteDataTable(strSqlPA2);
                    string numPA2 = dtCYJLPA2.Rows[0]["NUM"].ToString();

                    //平安3车数
                    string strSqlPA3 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='13' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='21'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA3 = DataAccess.ExecuteDataTable(strSqlPA3);
                    string numPA3 = dtCYJLPA3.Rows[0]["NUM"].ToString();

                    //安顺1车数
                    string strSqlAS1 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='15' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='21'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLAS1 = DataAccess.ExecuteDataTable(strSqlAS1);
                    string numAS1 = dtCYJLAS1.Rows[0]["NUM"].ToString();

                    //安顺2车数
                    string strSqlAS2 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='16' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='21'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLAS2 = DataAccess.ExecuteDataTable(strSqlAS2);
                    string numAS2 = dtCYJLAS2.Rows[0]["NUM"].ToString();

                    this.label24.Text = "平安1：" + numPA1+"辆" + " 平安2：" + numPA2 +"辆"+ "  平安3：" + numPA3+"辆" + "  安顺1：" + numAS1 + "辆"+"  安顺2：" + numAS2;
                } if (num6 == "0")
                {
                    this.label24.Text = "";
                }
                int num_int = 0;
                int num1_int = 0;
                int num2_int = 0;
                int num4_int = 0;
                int num5_int = 0;
                int num6_int = 0;

                int NUM_INT = 0;
                int NUM1_INT = 0;
                int NUM2_INT = 0;
                int NUM4_INT = 0;
                int NUM5_INT = 0;
                int NUM6_INT = 0;
                try
                {
                    num_int = int.Parse(num);
                    num1_int = int.Parse(num1);
                    num2_int = int.Parse(num2);
                    num4_int = int.Parse(num4);
                    num5_int = int.Parse(num5);
                    num6_int = int.Parse(num6);

                    NUM_INT = int.Parse(NUM);
                    NUM1_INT = int.Parse(NUM1);
                    NUM2_INT = int.Parse(NUM2);
                    NUM4_INT = int.Parse(NUM4);
                    NUM5_INT = int.Parse(NUM5);
                    NUM6_INT = int.Parse(NUM6);
                }
                catch (Exception e)
                {
                    throw e;
                }
                if (num_int > NUM_INT || num1_int > NUM1_INT || num2_int > NUM2_INT || num4_int > NUM4_INT || num5_int > NUM5_INT || num6_int > NUM6_INT)
                {
                    NUM = num;
                    NUM1 = num1;
                    NUM2 = num2;
                    NUM4 = num4;
                    NUM5 = num5;
                    NUM6 = num6;
                    SoundPlayer p = new SoundPlayer();
                    p.SoundLocation = Application.StartupPath + "\\test.wav";
                    p.Load();
                    p.Play();
                }
                else {
                    NUM = num;
                    NUM1 = num1;
                    NUM2 = num2;
                    NUM4 = num4;
                    NUM5 = num5;
                    NUM6 = num6;
                }
            }
            else if (Session.CurrentUserName == "ADMIN_AS")
            {
               

                //实华黄岛
                string strSql = "select t.PLAN_NO,t.TRUCK_NO,ORDER_TIME,decode(t.IF_END, '0','在场','1','离场') IF_END,decode(t.ORGCODE, '01','实华黄岛','02','实华董家口','03','摩科瑞','21','红星库区','22','天安','23','丽星','24','益佳','25','中油','11','平安停车场1','12','平安停车场2','13','平安停车场3','15','安顺停车场1','16','安顺停车场2','23','金赛物流停车场') ORGNAME,t.IN_PARK_TIME AS IN_DATE  from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p  where   t.IF_END='0' and (t.ORGCODE = '16' OR t.ORGCODE = '15') and t.plan_no=p.Plan_No and p.depot_code='01'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL = DataAccess.ExecuteDataTable(strSql);
                if (dtCYJL != null && dtCYJL.Rows.Count > 0)
                {
                    dtCYJL.Columns.Add("DRIVER_TEL", typeof(string));
                    for (int i = 0; i < dtCYJL.Rows.Count; i++)
                    {
                        string TRUCK_NO = dtCYJL.Rows[i]["TRUCK_NO"].ToString();
                        string PLAN_NO = dtCYJL.Rows[i]["PLAN_NO"].ToString();
                        string strSqlTel = "select d.phone as DRIVER_TEL from wlw_dbc_driver d where d.id in (select b.driver_id from wlw_dbc_oil_bill b where b.plan_no= '" + PLAN_NO + "' and head_car_id in (select i.id from wlw_dbc_oilcar_info i where i.car_no= '" + TRUCK_NO + "'))";
                        DataTable dtTel = DataAccess.ExecuteDataTable(strSqlTel);
                        if (dtTel != null && dtTel.Rows.Count > 0)
                        {
                            string DRIVER_TEL = dtTel.Rows[0]["DRIVER_TEL"].ToString();
                            dtCYJL.Rows[i]["DRIVER_TEL"] = DRIVER_TEL;
                        }
                    }
                   
                }
                this.cdgvGZJL.AutoGenerateColumns = false;
                this.cdgvGZJL.DataSource = dtCYJL;
                //进行统计
                string strSqlNum = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.IF_END='0' and (t.ORGCODE = '16' OR t.ORGCODE = '15') and t.plan_no=p.Plan_No and p.depot_code='01'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJLNum = DataAccess.ExecuteDataTable(strSqlNum);
                string num = dtCYJLNum.Rows[0]["NUM"].ToString();
                this.label2.Text = num;
                if (num != "0")
                {
                   
                    //安顺1车数
                    string strSqlAS1 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='15' AND  t.IF_END='0' and (t.ORGCODE = '16' OR t.ORGCODE = '15') and t.plan_no=p.Plan_No and p.depot_code='01'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLAS1 = DataAccess.ExecuteDataTable(strSqlAS1);
                    string numAS1 = dtCYJLAS1.Rows[0]["NUM"].ToString();

                    //安顺2车数
                    string strSqlAS2 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='16' AND  t.IF_END='0' and (t.ORGCODE = '16' OR t.ORGCODE = '15') and t.plan_no=p.Plan_No and p.depot_code='01'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLAS2 = DataAccess.ExecuteDataTable(strSqlAS2);
                    string numAS2 = dtCYJLAS2.Rows[0]["NUM"].ToString();

                    this.label19.Text = "安顺1：" + numAS1 + "   安顺2：" + numAS2;
                } if (num == "0")
                {
                    this.label19.Text = "";
                }
                //丽星
                string strSql1 = "select t.PLAN_NO,t.TRUCK_NO,ORDER_TIME,decode(t.IF_END, '0','在场','1','离场') IF_END,decode(t.ORGCODE, '01','实华黄岛','02','实华董家口','03','摩科瑞','21','红星库区','22','天安','23','丽星','24','益佳','25','中油','11','平安停车场1','12','平安停车场2','13','平安停车场3','15','安顺停车场1','16','安顺停车场2','23','金赛物流停车场') ORGNAME,t.IN_PARK_TIME AS IN_DATE  from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p  where    t.IF_END='0' and (t.ORGCODE = '16' OR t.ORGCODE = '15') and t.plan_no=p.Plan_No and p.depot_code='23'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL1 = DataAccess.ExecuteDataTable(strSql1);
                if (dtCYJL1 != null && dtCYJL1.Rows.Count > 0)
                {
                    dtCYJL1.Columns.Add("DRIVER_TEL", typeof(string));
                    for (int i = 0; i < dtCYJL1.Rows.Count; i++)
                    {
                        string TRUCK_NO = dtCYJL1.Rows[i]["TRUCK_NO"].ToString();
                        string PLAN_NO = dtCYJL1.Rows[i]["PLAN_NO"].ToString();
                        string strSqlTel = "select d.phone as DRIVER_TEL from wlw_dbc_driver d where d.id in (select b.driver_id from wlw_dbc_oil_bill b where b.plan_no= '" + PLAN_NO + "' and head_car_id in (select i.id from wlw_dbc_oilcar_info i where i.car_no= '" + TRUCK_NO + "'))";
                        DataTable dtTel = DataAccess.ExecuteDataTable(strSqlTel);
                        if (dtTel != null && dtTel.Rows.Count > 0)
                        {
                            string DRIVER_TEL = dtTel.Rows[0]["DRIVER_TEL"].ToString();
                            dtCYJL1.Rows[i]["DRIVER_TEL"] = DRIVER_TEL;
                        }
                    }
                   
                }
                this.cDataGridView1.AutoGenerateColumns = false;
                this.cDataGridView1.DataSource = dtCYJL1;
                //进行统计
                string strSql1Num = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.IF_END='0' and (t.ORGCODE = '16' OR t.ORGCODE = '15') and t.plan_no=p.Plan_No and p.depot_code='23'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL1Num = DataAccess.ExecuteDataTable(strSql1Num);
                string num1 = dtCYJL1Num.Rows[0]["NUM"].ToString();
                this.label10.Text = num1;
                if (num1 != "0")
                {

                    //安顺1车数
                    string strSqlAS1 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='15' AND  t.IF_END='0' and (t.ORGCODE = '16' OR t.ORGCODE = '15') and t.plan_no=p.Plan_No and p.depot_code='23'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLAS1 = DataAccess.ExecuteDataTable(strSqlAS1);
                    string numAS1 = dtCYJLAS1.Rows[0]["NUM"].ToString();

                    //安顺2车数
                    string strSqlAS2 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='16' AND  t.IF_END='0' and (t.ORGCODE = '16' OR t.ORGCODE = '15') and t.plan_no=p.Plan_No and p.depot_code='23'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLAS2 = DataAccess.ExecuteDataTable(strSqlAS2);
                    string numAS2 = dtCYJLAS2.Rows[0]["NUM"].ToString();

                    this.label20.Text = "安顺1：" + numAS1 + "   安顺2：" + numAS2;
                } if (num1 == "0")
                {
                    this.label20.Text = "";
                }
               
                //天安
                string strSql2 = "select t.PLAN_NO,t.TRUCK_NO,ORDER_TIME,decode(t.IF_END, '0','在场','1','离场') IF_END,decode(t.ORGCODE, '01','实华黄岛','02','实华董家口','03','摩科瑞','21','红星库区','22','天安','23','丽星','24','益佳','25','中油','11','平安停车场1','12','平安停车场2','13','平安停车场3','15','安顺停车场1','16','安顺停车场2','23','金赛物流停车场') ORGNAME,t.IN_PARK_TIME AS IN_DATE  from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p  where   t.IF_END='0' and (t.ORGCODE = '16' OR t.ORGCODE = '15') and t.plan_no=p.Plan_No and p.depot_code='22'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL2 = DataAccess.ExecuteDataTable(strSql2);
                if (dtCYJL2 != null && dtCYJL2.Rows.Count > 0)
                {
                    dtCYJL2.Columns.Add("DRIVER_TEL", typeof(string));
                    for (int i = 0; i < dtCYJL2.Rows.Count; i++)
                    {
                        string TRUCK_NO = dtCYJL2.Rows[i]["TRUCK_NO"].ToString();
                        string PLAN_NO = dtCYJL2.Rows[i]["PLAN_NO"].ToString();
                        string strSqlTel = "select d.phone as DRIVER_TEL from wlw_dbc_driver d where d.id in (select b.driver_id from wlw_dbc_oil_bill b where b.plan_no= '" + PLAN_NO + "' and head_car_id in (select i.id from wlw_dbc_oilcar_info i where i.car_no= '" + TRUCK_NO + "'))";
                        DataTable dtTel = DataAccess.ExecuteDataTable(strSqlTel);
                        if (dtTel != null && dtTel.Rows.Count > 0)
                        {
                            string DRIVER_TEL = dtTel.Rows[0]["DRIVER_TEL"].ToString();
                            dtCYJL2.Rows[i]["DRIVER_TEL"] = DRIVER_TEL;
                        }
                    }
                    
                }
                this.cDataGridView2.AutoGenerateColumns = false;
                this.cDataGridView2.DataSource = dtCYJL2;
                //进行统计
                string strSql2Num = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where  t.IF_END='0' and (t.ORGCODE = '16' OR t.ORGCODE = '15') and t.plan_no=p.Plan_No and p.depot_code='22'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL2Num = DataAccess.ExecuteDataTable(strSql2Num);
                string num2 = dtCYJL2Num.Rows[0]["NUM"].ToString();
                this.label12.Text = num2;
                if (num2 != "0")
                {

                    //安顺1车数
                    string strSqlAS1 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='15' AND  t.IF_END='0' and (t.ORGCODE = '16' OR t.ORGCODE = '15') and t.plan_no=p.Plan_No and p.depot_code='22'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLAS1 = DataAccess.ExecuteDataTable(strSqlAS1);
                    string numAS1 = dtCYJLAS1.Rows[0]["NUM"].ToString();

                    //安顺2车数
                    string strSqlAS2 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='16' AND  t.IF_END='0' and (t.ORGCODE = '16' OR t.ORGCODE = '15') and t.plan_no=p.Plan_No and p.depot_code='22'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLAS2 = DataAccess.ExecuteDataTable(strSqlAS2);
                    string numAS2 = dtCYJLAS2.Rows[0]["NUM"].ToString();

                    this.label21.Text = "安顺1：" + numAS1 + "   安顺2：" + numAS2;
                } if (num2 == "0")
                {
                    this.label21.Text = "";
                }

                //益佳
                string strSql3 = "select t.PLAN_NO,t.TRUCK_NO,ORDER_TIME,decode(t.IF_END, '0','在场','1','离场') IF_END,decode(t.ORGCODE, '01','实华黄岛','02','实华董家口','03','摩科瑞','21','红星库区','22','天安','23','丽星','24','益佳','25','中油','11','平安停车场1','12','平安停车场2','13','平安停车场3','15','安顺停车场1','16','安顺停车场2','23','金赛物流停车场') ORGNAME,t.IN_PARK_TIME AS IN_DATE  from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p  where    t.IF_END='0' and (t.ORGCODE = '16' OR t.ORGCODE = '15') and t.plan_no=p.Plan_No and p.depot_code='24'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL3 = DataAccess.ExecuteDataTable(strSql3);
                if (dtCYJL3 != null && dtCYJL3.Rows.Count > 0)
                {
                    dtCYJL3.Columns.Add("DRIVER_TEL", typeof(string));
                    for (int i = 0; i < dtCYJL3.Rows.Count; i++)
                    {
                        string TRUCK_NO = dtCYJL3.Rows[i]["TRUCK_NO"].ToString();
                        string PLAN_NO = dtCYJL3.Rows[i]["PLAN_NO"].ToString();
                        string strSqlTel = "select d.phone as DRIVER_TEL from wlw_dbc_driver d where d.id in (select b.driver_id from wlw_dbc_oil_bill b where b.plan_no= '" + PLAN_NO + "' and head_car_id in (select i.id from wlw_dbc_oilcar_info i where i.car_no= '" + TRUCK_NO + "'))";
                        DataTable dtTel = DataAccess.ExecuteDataTable(strSqlTel);
                        if (dtTel != null && dtTel.Rows.Count > 0)
                        {
                            string DRIVER_TEL = dtTel.Rows[0]["DRIVER_TEL"].ToString();
                            dtCYJL3.Rows[i]["DRIVER_TEL"] = DRIVER_TEL;
                        }
                    }
                    
                }
                this.cDataGridView3.AutoGenerateColumns = false;
                this.cDataGridView3.DataSource = dtCYJL3;
                //进行统计
                string strSql4Num = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.IF_END='0' and (t.ORGCODE = '16' OR t.ORGCODE = '15') and t.plan_no=p.Plan_No and p.depot_code='24'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL4Num = DataAccess.ExecuteDataTable(strSql4Num);
                string num4 = dtCYJL4Num.Rows[0]["NUM"].ToString();
                this.label14.Text = num4;
                if (num4 != "0")
                {

                    //安顺1车数
                    string strSqlAS1 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='15' AND  t.IF_END='0' and (t.ORGCODE = '16' OR t.ORGCODE = '15') and t.plan_no=p.Plan_No and p.depot_code='24'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLAS1 = DataAccess.ExecuteDataTable(strSqlAS1);
                    string numAS1 = dtCYJLAS1.Rows[0]["NUM"].ToString();

                    //安顺2车数
                    string strSqlAS2 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='16' AND  t.IF_END='0' and (t.ORGCODE = '16' OR t.ORGCODE = '15') and t.plan_no=p.Plan_No and p.depot_code='24'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLAS2 = DataAccess.ExecuteDataTable(strSqlAS2);
                    string numAS2 = dtCYJLAS2.Rows[0]["NUM"].ToString();

                    this.label22.Text = "安顺1：" + numAS1 + "   安顺2：" + numAS2;
                } if (num4 == "0")
                {
                    this.label22.Text = "";
                }

                //中油
                string strSql4 = "select t.PLAN_NO,t.TRUCK_NO,ORDER_TIME,decode(t.IF_END, '0','在场','1','离场') IF_END,decode(t.ORGCODE, '01','实华黄岛','02','实华董家口','03','摩科瑞','21','红星库区','22','天安','23','丽星','24','益佳','25','中油','11','平安停车场1','12','平安停车场2','13','平安停车场3','15','安顺停车场1','16','安顺停车场2','23','金赛物流停车场') ORGNAME ,t.IN_PARK_TIME AS IN_DATE  from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p  where    t.IF_END='0' and (t.ORGCODE = '16' OR t.ORGCODE = '15') and t.plan_no=p.Plan_No and p.depot_code='25'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL4 = DataAccess.ExecuteDataTable(strSql4);
                if (dtCYJL4 != null && dtCYJL4.Rows.Count > 0)
                {
                    dtCYJL4.Columns.Add("DRIVER_TEL", typeof(string));
                    for (int i = 0; i < dtCYJL4.Rows.Count; i++)
                    {
                        string TRUCK_NO = dtCYJL4.Rows[i]["TRUCK_NO"].ToString();
                        string PLAN_NO = dtCYJL4.Rows[i]["PLAN_NO"].ToString();
                        string strSqlTel = "select d.phone as DRIVER_TEL from wlw_dbc_driver d where d.id in (select b.driver_id from wlw_dbc_oil_bill b where b.plan_no= '" + PLAN_NO + "' and head_car_id in (select i.id from wlw_dbc_oilcar_info i where i.car_no= '" + TRUCK_NO + "'))";
                        DataTable dtTel = DataAccess.ExecuteDataTable(strSqlTel);
                        if (dtTel != null && dtTel.Rows.Count > 0)
                        {
                            string DRIVER_TEL = dtTel.Rows[0]["DRIVER_TEL"].ToString();
                            dtCYJL4.Rows[i]["DRIVER_TEL"] = DRIVER_TEL;
                        }
                    }
                    
                }
                this.cDataGridView4.AutoGenerateColumns = false;
                this.cDataGridView4.DataSource = dtCYJL4;
                //进行统计
                string strSql5Num = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.IF_END='0' and (t.ORGCODE = '16' OR t.ORGCODE = '15') and t.plan_no=p.Plan_No and p.depot_code='25'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL5Num = DataAccess.ExecuteDataTable(strSql5Num);
                string num5 = dtCYJL5Num.Rows[0]["NUM"].ToString();
                this.label16.Text = num5;
                if (num5 != "0")
                {

                    //安顺1车数
                    string strSqlAS1 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='15' AND  t.IF_END='0' and (t.ORGCODE = '16' OR t.ORGCODE = '15') and t.plan_no=p.Plan_No and p.depot_code='25'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLAS1 = DataAccess.ExecuteDataTable(strSqlAS1);
                    string numAS1 = dtCYJLAS1.Rows[0]["NUM"].ToString();

                    //安顺2车数
                    string strSqlAS2 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='16' AND  t.IF_END='0' and (t.ORGCODE = '16' OR t.ORGCODE = '15') and t.plan_no=p.Plan_No and p.depot_code='25'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLAS2 = DataAccess.ExecuteDataTable(strSqlAS2);
                    string numAS2 = dtCYJLAS2.Rows[0]["NUM"].ToString();

                    this.label23.Text = "安顺1：" + numAS1 + "   安顺2：" + numAS2;
                } if (num5 == "0")
                {
                    this.label23.Text = "";
                }
                //红星
                string strSql5 = "select t.PLAN_NO,t.TRUCK_NO,ORDER_TIME,decode(t.IF_END, '0','在场','1','离场') IF_END,decode(t.ORGCODE, '01','实华黄岛','02','实华董家口','03','摩科瑞','21','红星库区','22','天安','23','丽星','24','益佳','25','中油','11','平安停车场1','12','平安停车场2','13','平安停车场3','15','安顺停车场1','16','安顺停车场2','23','金赛物流停车场') ORGNAME ,t.IN_PARK_TIME AS IN_DATE  from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p  where    t.IF_END='0' and (t.ORGCODE = '16' OR t.ORGCODE = '15') and t.plan_no=p.Plan_No and p.depot_code='21'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL5 = DataAccess.ExecuteDataTable(strSql5);
                if (dtCYJL5 != null && dtCYJL5.Rows.Count > 0)
                {
                    dtCYJL5.Columns.Add("DRIVER_TEL", typeof(string));
                    for (int i = 0; i < dtCYJL5.Rows.Count; i++)
                    {
                        string TRUCK_NO = dtCYJL5.Rows[i]["TRUCK_NO"].ToString();
                        string PLAN_NO = dtCYJL5.Rows[i]["PLAN_NO"].ToString();
                        string strSqlTel = "select d.phone as DRIVER_TEL from wlw_dbc_driver d where d.id in (select b.driver_id from wlw_dbc_oil_bill b where b.plan_no= '" + PLAN_NO + "' and head_car_id in (select i.id from wlw_dbc_oilcar_info i where i.car_no= '" + TRUCK_NO + "'))";
                        DataTable dtTel = DataAccess.ExecuteDataTable(strSqlTel);
                        if (dtTel != null && dtTel.Rows.Count > 0)
                        {
                            string DRIVER_TEL = dtTel.Rows[0]["DRIVER_TEL"].ToString();
                            dtCYJL5.Rows[i]["DRIVER_TEL"] = DRIVER_TEL;
                        }
                    }
                    
                }
                this.cDataGridView5.AutoGenerateColumns = false;
                this.cDataGridView5.DataSource = dtCYJL5;
                //进行统计
                string strSql6Num = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.IF_END='0' and (t.ORGCODE = '16' OR t.ORGCODE = '15') and t.plan_no=p.Plan_No and p.depot_code='21'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL6Num = DataAccess.ExecuteDataTable(strSql6Num);
                string num6 = dtCYJL6Num.Rows[0]["NUM"].ToString();
                this.label18.Text = num6;
                if (num6 != "0")
                {

                    //安顺1车数
                    string strSqlAS1 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='15' AND  t.IF_END='0' and (t.ORGCODE = '16' OR t.ORGCODE = '15') and t.plan_no=p.Plan_No and p.depot_code='21'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLAS1 = DataAccess.ExecuteDataTable(strSqlAS1);
                    string numAS1 = dtCYJLAS1.Rows[0]["NUM"].ToString();

                    //安顺2车数
                    string strSqlAS2 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='16' AND  t.IF_END='0' and (t.ORGCODE = '16' OR t.ORGCODE = '15') and t.plan_no=p.Plan_No and p.depot_code='21'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLAS2 = DataAccess.ExecuteDataTable(strSqlAS2);
                    string numAS2 = dtCYJLAS2.Rows[0]["NUM"].ToString();

                    this.label24.Text = "安顺1：" + numAS1 + "   安顺2：" + numAS2;
                } if (num6 == "0")
                {
                    this.label24.Text = "";
                }
                int num_int = 0;
                int num1_int = 0;
                int num2_int = 0;
                int num4_int = 0;
                int num5_int = 0;
                int num6_int = 0;

                int NUM_INT = 0;
                int NUM1_INT = 0;
                int NUM2_INT = 0;
                int NUM4_INT = 0;
                int NUM5_INT = 0;
                int NUM6_INT = 0;
                try
                {
                    num_int = int.Parse(num);
                    num1_int = int.Parse(num1);
                    num2_int = int.Parse(num2);
                    num4_int = int.Parse(num4);
                    num5_int = int.Parse(num5);
                    num6_int = int.Parse(num6);

                    NUM_INT = int.Parse(NUM);
                    NUM1_INT = int.Parse(NUM1);
                    NUM2_INT = int.Parse(NUM2);
                    NUM4_INT = int.Parse(NUM4);
                    NUM5_INT = int.Parse(NUM5);
                    NUM6_INT = int.Parse(NUM6);
                }
                catch (Exception e)
                {
                    throw e;
                }
                if (num_int > NUM_INT || num1_int > NUM1_INT || num2_int > NUM2_INT || num4_int > NUM4_INT || num5_int > NUM5_INT || num6_int > NUM6_INT)
                {
                    NUM = num;
                    NUM1 = num1;
                    NUM2 = num2;
                    NUM4 = num4;
                    NUM5 = num5;
                    NUM6 = num6;
                    SoundPlayer p = new SoundPlayer();
                    p.SoundLocation = Application.StartupPath + "\\test.wav";
                    p.Load();
                    p.Play();
                }
                else
                {
                    NUM = num;
                    NUM1 = num1;
                    NUM2 = num2;
                    NUM4 = num4;
                    NUM5 = num5;
                    NUM6 = num6;
                }
            }
            else if (Session.CurrentUserName == "ADMIN_PA")
            {
                //实华黄岛
                string strSql = "select t.PLAN_NO,t.TRUCK_NO,ORDER_TIME,decode(t.IF_END, '0','在场','1','离场') IF_END,decode(t.ORGCODE, '01','实华黄岛','02','实华董家口','03','摩科瑞','21','红星库区','22','天安','23','丽星','24','益佳','25','中油','11','平安停车场1','12','平安停车场2','13','平安停车场3','15','安顺停车场1','16','安顺停车场2','23','金赛物流停车场') ORGNAME,t.IN_PARK_TIME AS IN_DATE  from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p  where    t.IF_END='0' and (t.ORGCODE = '11' OR t.ORGCODE = '12' OR t.ORGCODE = '13') and t.plan_no=p.Plan_No and p.depot_code='01'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL = DataAccess.ExecuteDataTable(strSql);
                if (dtCYJL != null && dtCYJL.Rows.Count > 0)
                {
                    dtCYJL.Columns.Add("DRIVER_TEL", typeof(string));
                    for (int i = 0; i < dtCYJL.Rows.Count; i++)
                    {
                        string TRUCK_NO = dtCYJL.Rows[i]["TRUCK_NO"].ToString();
                        string PLAN_NO = dtCYJL.Rows[i]["PLAN_NO"].ToString();
                        string strSqlTel = "select d.phone as DRIVER_TEL from wlw_dbc_driver d where d.id in (select b.driver_id from wlw_dbc_oil_bill b where b.plan_no= '" + PLAN_NO + "' and head_car_id in (select i.id from wlw_dbc_oilcar_info i where i.car_no= '" + TRUCK_NO + "'))";
                        DataTable dtTel = DataAccess.ExecuteDataTable(strSqlTel);
                        if (dtTel != null && dtTel.Rows.Count > 0)
                        {
                            string DRIVER_TEL = dtTel.Rows[0]["DRIVER_TEL"].ToString();
                            dtCYJL.Rows[i]["DRIVER_TEL"] = DRIVER_TEL;
                        }
                    }
                   
                }
                this.cdgvGZJL.AutoGenerateColumns = false;
                this.cdgvGZJL.DataSource = dtCYJL;
                //进行统计
                string strSqlNum = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.IF_END='0' and (t.ORGCODE = '11' OR t.ORGCODE = '12' OR t.ORGCODE = '13') and t.plan_no=p.Plan_No and p.depot_code='01'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJLNum = DataAccess.ExecuteDataTable(strSqlNum);
                string num = dtCYJLNum.Rows[0]["NUM"].ToString();
                this.label2.Text = num;
                if (num != "0")
                {
                    //平安1车数
                    string strSqlPA1 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='11' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='01'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA1 = DataAccess.ExecuteDataTable(strSqlPA1);
                    string numPA1 = dtCYJLPA1.Rows[0]["NUM"].ToString();

                    //平安2车数
                    string strSqlPA2 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='12' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='01'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA2 = DataAccess.ExecuteDataTable(strSqlPA2);
                    string numPA2 = dtCYJLPA2.Rows[0]["NUM"].ToString();

                    //平安3车数
                    string strSqlPA3 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='13' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='01'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA3 = DataAccess.ExecuteDataTable(strSqlPA3);
                    string numPA3 = dtCYJLPA3.Rows[0]["NUM"].ToString();

                    this.label19.Text = "平安1：" + numPA1  + "   平安2：" + numPA2  + "   平安3：" + numPA3 ;
                } if (num == "0")
                {
                    this.label19.Text = "";
                }
                //丽星
                string strSql1 = "select t.PLAN_NO,t.TRUCK_NO,ORDER_TIME,decode(t.IF_END, '0','在场','1','离场') IF_END,decode(t.ORGCODE, '01','实华黄岛','02','实华董家口','03','摩科瑞','21','红星库区','22','天安','23','丽星','24','益佳','25','中油','11','平安停车场1','12','平安停车场2','13','平安停车场3','15','安顺停车场1','16','安顺停车场2','23','金赛物流停车场') ORGNAME,t.IN_PARK_TIME AS IN_DATE  from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p  where    t.IF_END='0' and (t.ORGCODE = '11' OR t.ORGCODE = '12' OR t.ORGCODE = '13') and t.plan_no=p.Plan_No and p.depot_code='23'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL1 = DataAccess.ExecuteDataTable(strSql1);
                if (dtCYJL1 != null && dtCYJL1.Rows.Count > 0)
                {
                    dtCYJL1.Columns.Add("DRIVER_TEL", typeof(string));
                    for (int i = 0; i < dtCYJL1.Rows.Count; i++)
                    {
                        string TRUCK_NO = dtCYJL1.Rows[i]["TRUCK_NO"].ToString();
                        string PLAN_NO = dtCYJL1.Rows[i]["PLAN_NO"].ToString();
                        string strSqlTel = "select d.phone as DRIVER_TEL from wlw_dbc_driver d where d.id in (select b.driver_id from wlw_dbc_oil_bill b where b.plan_no= '" + PLAN_NO + "' and head_car_id in (select i.id from wlw_dbc_oilcar_info i where i.car_no= '" + TRUCK_NO + "'))";
                        DataTable dtTel = DataAccess.ExecuteDataTable(strSqlTel);
                        if (dtTel != null && dtTel.Rows.Count > 0)
                        {
                            string DRIVER_TEL = dtTel.Rows[0]["DRIVER_TEL"].ToString();
                            dtCYJL1.Rows[i]["DRIVER_TEL"] = DRIVER_TEL;
                        }
                    }
                    
                }
                this.cDataGridView1.AutoGenerateColumns = false;
                this.cDataGridView1.DataSource = dtCYJL1;
                //进行统计
                string strSql1Num = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.IF_END='0' and (t.ORGCODE = '11' OR t.ORGCODE = '12' or t.ORGCODE = '13') and t.plan_no=p.Plan_No and p.depot_code='23'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL1Num = DataAccess.ExecuteDataTable(strSql1Num);
                string num1 = dtCYJL1Num.Rows[0]["NUM"].ToString();
                this.label10.Text = num1;
                if (num1 != "0")
                {
                    //平安1车数
                    string strSqlPA1 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='11' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='23'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA1 = DataAccess.ExecuteDataTable(strSqlPA1);
                    string numPA1 = dtCYJLPA1.Rows[0]["NUM"].ToString();

                    //平安2车数
                    string strSqlPA2 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='12' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='23'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA2 = DataAccess.ExecuteDataTable(strSqlPA2);
                    string numPA2 = dtCYJLPA2.Rows[0]["NUM"].ToString();

                    //平安3车数
                    string strSqlPA3 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='13' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='23'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA3 = DataAccess.ExecuteDataTable(strSqlPA3);
                    string numPA3 = dtCYJLPA3.Rows[0]["NUM"].ToString();

                    this.label20.Text = "平安1：" + numPA1 + "   平安2：" + numPA2 + "   平安3：" + numPA3;
                } if (num1 == "0")
                {
                    this.label20.Text = "";
                }

                //天安
                string strSql2 = "select t.PLAN_NO,t.TRUCK_NO,ORDER_TIME,decode(t.IF_END, '0','在场','1','离场') IF_END,decode(t.ORGCODE, '01','实华黄岛','02','实华董家口','03','摩科瑞','21','红星库区','22','天安','23','丽星','24','益佳','25','中油','11','平安停车场1','12','平安停车场2','13','平安停车场3','15','安顺停车场1','16','安顺停车场2','23','金赛物流停车场') ORGNAME ,t.IN_PARK_TIME AS IN_DATE  from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p  where    t.IF_END='0' and (t.ORGCODE = '11' OR t.ORGCODE = '12' OR t.ORGCODE = '13') and t.plan_no=p.Plan_No and p.depot_code='22'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL2 = DataAccess.ExecuteDataTable(strSql2);
                if (dtCYJL2 != null && dtCYJL2.Rows.Count > 0)
                {
                    dtCYJL2.Columns.Add("DRIVER_TEL", typeof(string));
                    for (int i = 0; i < dtCYJL2.Rows.Count; i++)
                    {
                        string TRUCK_NO = dtCYJL2.Rows[i]["TRUCK_NO"].ToString();
                        string PLAN_NO = dtCYJL2.Rows[i]["PLAN_NO"].ToString();
                        string strSqlTel = "select d.phone as DRIVER_TEL from wlw_dbc_driver d where d.id in (select b.driver_id from wlw_dbc_oil_bill b where b.plan_no= '" + PLAN_NO + "' and head_car_id in (select i.id from wlw_dbc_oilcar_info i where i.car_no= '" + TRUCK_NO + "'))";
                        DataTable dtTel = DataAccess.ExecuteDataTable(strSqlTel);
                        if (dtTel != null && dtTel.Rows.Count > 0)
                        {
                            string DRIVER_TEL = dtTel.Rows[0]["DRIVER_TEL"].ToString();
                            dtCYJL2.Rows[i]["DRIVER_TEL"] = DRIVER_TEL;
                        }
                    }
                    
                }
                this.cDataGridView2.AutoGenerateColumns = false;
                this.cDataGridView2.DataSource = dtCYJL2;
                //进行统计
                string strSql2Num = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where  t.IF_END='0' and (t.ORGCODE = '11' OR t.ORGCODE = '12' OR t.ORGCODE = '13') and t.plan_no=p.Plan_No and p.depot_code='22'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL2Num = DataAccess.ExecuteDataTable(strSql2Num);
                string num2 = dtCYJL2Num.Rows[0]["NUM"].ToString();
                this.label12.Text = num2;
                if (num2 != "0")
                {
                    //平安1车数
                    string strSqlPA1 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='11' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='22'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA1 = DataAccess.ExecuteDataTable(strSqlPA1);
                    string numPA1 = dtCYJLPA1.Rows[0]["NUM"].ToString();

                    //平安2车数
                    string strSqlPA2 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='12' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='22'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA2 = DataAccess.ExecuteDataTable(strSqlPA2);
                    string numPA2 = dtCYJLPA2.Rows[0]["NUM"].ToString();

                    //平安3车数
                    string strSqlPA3 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='13' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='22'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA3 = DataAccess.ExecuteDataTable(strSqlPA3);
                    string numPA3 = dtCYJLPA3.Rows[0]["NUM"].ToString();

                    this.label21.Text = "平安1：" + numPA1 + "   平安2：" + numPA2 + "   平安3：" + numPA3;
                } if (num2 == "0")
                {
                    this.label21.Text = "";
                }
                //益佳
                string strSql3 = "select t.PLAN_NO,t.TRUCK_NO,ORDER_TIME,decode(t.IF_END, '0','在场','1','离场') IF_END,decode(t.ORGCODE, '01','实华黄岛','02','实华董家口','03','摩科瑞','21','红星库区','22','天安','23','丽星','24','益佳','25','中油','11','平安停车场1','12','平安停车场2','13','平安停车场3','15','安顺停车场1','16','安顺停车场2','23','金赛物流停车场') ORGNAME ,t.IN_PARK_TIME AS IN_DATE  from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p  where    t.IF_END='0' and (t.ORGCODE = '11' OR t.ORGCODE = '12' OR t.ORGCODE = '13') and t.plan_no=p.Plan_No  and p.depot_code='24' ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL3 = DataAccess.ExecuteDataTable(strSql3);
                if (dtCYJL3 != null && dtCYJL3.Rows.Count > 0)
                {
                    dtCYJL3.Columns.Add("DRIVER_TEL", typeof(string));
                    for (int i = 0; i < dtCYJL3.Rows.Count; i++)
                    {
                        string TRUCK_NO = dtCYJL3.Rows[i]["TRUCK_NO"].ToString();
                        string PLAN_NO = dtCYJL3.Rows[i]["PLAN_NO"].ToString();
                        string strSqlTel = "select d.phone as DRIVER_TEL from wlw_dbc_driver d where d.id in (select b.driver_id from wlw_dbc_oil_bill b where b.plan_no= '" + PLAN_NO + "' and head_car_id in (select i.id from wlw_dbc_oilcar_info i where i.car_no= '" + TRUCK_NO + "'))";
                        DataTable dtTel = DataAccess.ExecuteDataTable(strSqlTel);
                        if (dtTel != null && dtTel.Rows.Count > 0)
                        {
                            string DRIVER_TEL = dtTel.Rows[0]["DRIVER_TEL"].ToString();
                            dtCYJL3.Rows[i]["DRIVER_TEL"] = DRIVER_TEL;
                        }
                    }
                    
                }
                this.cDataGridView3.AutoGenerateColumns = false;
                this.cDataGridView3.DataSource = dtCYJL3;
                //进行统计
                string strSql4Num = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.IF_END='0' and (t.ORGCODE = '11' OR t.ORGCODE = '12' OR t.ORGCODE = '13') and t.plan_no=p.Plan_No and p.depot_code='24'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL4Num = DataAccess.ExecuteDataTable(strSql4Num);
                string num4 = dtCYJL4Num.Rows[0]["NUM"].ToString();
                this.label14.Text = num4;
                if (num4 != "0")
                {
                    //平安1车数
                    string strSqlPA1 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='11' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='24'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA1 = DataAccess.ExecuteDataTable(strSqlPA1);
                    string numPA1 = dtCYJLPA1.Rows[0]["NUM"].ToString();

                    //平安2车数
                    string strSqlPA2 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='12' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='24'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA2 = DataAccess.ExecuteDataTable(strSqlPA2);
                    string numPA2 = dtCYJLPA2.Rows[0]["NUM"].ToString();

                    //平安3车数
                    string strSqlPA3 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='13' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='24'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA3 = DataAccess.ExecuteDataTable(strSqlPA3);
                    string numPA3 = dtCYJLPA3.Rows[0]["NUM"].ToString();

                    this.label22.Text = "平安1：" + numPA1 + "   平安2：" + numPA2 + "   平安3：" + numPA3;
                } if (num4 == "0")
                {
                    this.label22.Text = "";
                }
                //中油
                string strSql4 = "select t.PLAN_NO,t.TRUCK_NO,ORDER_TIME,decode(t.IF_END, '0','在场','1','离场') IF_END,decode(t.ORGCODE, '01','实华黄岛','02','实华董家口','03','摩科瑞','21','红星库区','22','天安','23','丽星','24','益佳','25','中油','11','平安停车场1','12','平安停车场2','13','平安停车场3','15','安顺停车场1','16','安顺停车场2','23','金赛物流停车场') ORGNAME ,t.IN_PARK_TIME AS IN_DATE  from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p  where    t.IF_END='0' and (t.ORGCODE = '11' OR t.ORGCODE = '12' OR t.ORGCODE = '13') and t.plan_no=p.Plan_No and p.depot_code='25'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL4 = DataAccess.ExecuteDataTable(strSql4);
                if (dtCYJL4 != null && dtCYJL4.Rows.Count > 0)
                {
                    dtCYJL4.Columns.Add("DRIVER_TEL", typeof(string));
                    for (int i = 0; i < dtCYJL4.Rows.Count; i++)
                    {
                        string TRUCK_NO = dtCYJL4.Rows[i]["TRUCK_NO"].ToString();
                        string PLAN_NO = dtCYJL4.Rows[i]["PLAN_NO"].ToString();
                        string strSqlTel = "select d.phone as DRIVER_TEL from wlw_dbc_driver d where d.id in (select b.driver_id from wlw_dbc_oil_bill b where b.plan_no= '" + PLAN_NO + "' and head_car_id in (select i.id from wlw_dbc_oilcar_info i where i.car_no= '" + TRUCK_NO + "'))";
                        DataTable dtTel = DataAccess.ExecuteDataTable(strSqlTel);
                        if (dtTel != null && dtTel.Rows.Count > 0)
                        {
                            string DRIVER_TEL = dtTel.Rows[0]["DRIVER_TEL"].ToString();
                            dtCYJL4.Rows[i]["DRIVER_TEL"] = DRIVER_TEL;
                        }
                    }
                   
                }
                this.cDataGridView4.AutoGenerateColumns = false;
                this.cDataGridView4.DataSource = dtCYJL4;
                //进行统计
                string strSql5Num = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.IF_END='0' and (t.ORGCODE = '11' OR t.ORGCODE = '12' OR t.ORGCODE = '13') and t.plan_no=p.Plan_No and p.depot_code='25'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL5Num = DataAccess.ExecuteDataTable(strSql5Num);
                string num5 = dtCYJL5Num.Rows[0]["NUM"].ToString();
                this.label16.Text = num5;
                if (num5 != "0")
                {
                    //平安1车数
                    string strSqlPA1 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='11' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='25'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA1 = DataAccess.ExecuteDataTable(strSqlPA1);
                    string numPA1 = dtCYJLPA1.Rows[0]["NUM"].ToString();

                    //平安2车数
                    string strSqlPA2 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='12' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='25'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA2 = DataAccess.ExecuteDataTable(strSqlPA2);
                    string numPA2 = dtCYJLPA2.Rows[0]["NUM"].ToString();

                    //平安3车数
                    string strSqlPA3 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='13' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='25'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA3 = DataAccess.ExecuteDataTable(strSqlPA3);
                    string numPA3 = dtCYJLPA3.Rows[0]["NUM"].ToString();

                    this.label23.Text = "平安1：" + numPA1 + "   平安2：" + numPA2 + "   平安3：" + numPA3;
                } if (num5 == "0")
                {
                    this.label23.Text = "";
                }
                //红星
                string strSql5 = "select t.PLAN_NO,t.TRUCK_NO,ORDER_TIME,decode(t.IF_END, '0','在场','1','离场') IF_END,decode(t.ORGCODE, '01','实华黄岛','02','实华董家口','03','摩科瑞','21','红星库区','22','天安','23','丽星','24','益佳','25','中油','11','平安停车场1','12','平安停车场2','13','平安停车场3','15','安顺停车场1','16','安顺停车场2','23','金赛物流停车场') ORGNAME ,t.IN_PARK_TIME AS IN_DATE  from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p  where    t.IF_END='0' and (t.ORGCODE = '11' OR t.ORGCODE = '12' OR t.ORGCODE = '13') and t.plan_no=p.Plan_No and p.depot_code='21'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL5 = DataAccess.ExecuteDataTable(strSql5);
                if (dtCYJL5 != null && dtCYJL5.Rows.Count > 0)
                {
                    dtCYJL5.Columns.Add("DRIVER_TEL", typeof(string));
                    for (int i = 0; i < dtCYJL5.Rows.Count; i++)
                    {
                        string TRUCK_NO = dtCYJL5.Rows[i]["TRUCK_NO"].ToString();
                        string PLAN_NO = dtCYJL5.Rows[i]["PLAN_NO"].ToString();
                        string strSqlTel = "select d.phone as DRIVER_TEL from wlw_dbc_driver d where d.id in (select b.driver_id from wlw_dbc_oil_bill b where b.plan_no= '" + PLAN_NO + "' and head_car_id in (select i.id from wlw_dbc_oilcar_info i where i.car_no= '" + TRUCK_NO + "'))";
                        DataTable dtTel = DataAccess.ExecuteDataTable(strSqlTel);
                        if (dtTel != null && dtTel.Rows.Count > 0)
                        {
                            string DRIVER_TEL = dtTel.Rows[0]["DRIVER_TEL"].ToString();
                            dtCYJL5.Rows[i]["DRIVER_TEL"] = DRIVER_TEL;
                        }
                    }
                   
                }
                this.cDataGridView5.AutoGenerateColumns = false;
                this.cDataGridView5.DataSource = dtCYJL5;
                //进行统计
                string strSql6Num = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.IF_END='0' and (t.ORGCODE = '11' OR t.ORGCODE = '12' OR t.ORGCODE = '13') and t.plan_no=p.Plan_No and p.depot_code='21'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL6Num = DataAccess.ExecuteDataTable(strSql6Num);
                string num6 = dtCYJL6Num.Rows[0]["NUM"].ToString();
                this.label18.Text = num6;
                if (num6 != "0")
                {
                    //平安1车数
                    string strSqlPA1 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='11' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='21'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA1 = DataAccess.ExecuteDataTable(strSqlPA1);
                    string numPA1 = dtCYJLPA1.Rows[0]["NUM"].ToString();

                    //平安2车数
                    string strSqlPA2 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='12' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='21'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA2 = DataAccess.ExecuteDataTable(strSqlPA2);
                    string numPA2 = dtCYJLPA2.Rows[0]["NUM"].ToString();

                    //平安3车数
                    string strSqlPA3 = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.ORGCODE='13' AND  t.IF_END='0' and t.plan_no=p.Plan_No and p.depot_code='21'  ORDER BY t.ORDER_TIME ASC";
                    DataTable dtCYJLPA3 = DataAccess.ExecuteDataTable(strSqlPA3);
                    string numPA3 = dtCYJLPA3.Rows[0]["NUM"].ToString();

                    this.label24.Text = "平安1：" + numPA1 + "   平安2：" + numPA2 + "   平安3：" + numPA3;
                } if (num6 == "0")
                {
                    this.label24.Text = "";
                }
                int num_int = 0;
                int num1_int = 0;
                int num2_int = 0;
                int num4_int = 0;
                int num5_int = 0;
                int num6_int = 0;

                int NUM_INT = 0;
                int NUM1_INT = 0;
                int NUM2_INT = 0;
                int NUM4_INT = 0;
                int NUM5_INT = 0;
                int NUM6_INT = 0;
                try
                {
                    num_int = int.Parse(num);
                    num1_int = int.Parse(num1);
                    num2_int = int.Parse(num2);
                    num4_int = int.Parse(num4);
                    num5_int = int.Parse(num5);
                    num6_int = int.Parse(num6);

                    NUM_INT = int.Parse(NUM);
                    NUM1_INT = int.Parse(NUM1);
                    NUM2_INT = int.Parse(NUM2);
                    NUM4_INT = int.Parse(NUM4);
                    NUM5_INT = int.Parse(NUM5);
                    NUM6_INT = int.Parse(NUM6);
                }
                catch (Exception e)
                {
                    throw e;
                }
                if (num_int > NUM_INT || num1_int > NUM1_INT || num2_int > NUM2_INT || num4_int > NUM4_INT || num5_int > NUM5_INT || num6_int > NUM6_INT)
                {
                    NUM = num;
                    NUM1 = num1;
                    NUM2 = num2;
                    NUM4 = num4;
                    NUM5 = num5;
                    NUM6 = num6;
                    SoundPlayer p = new SoundPlayer();
                    p.SoundLocation = Application.StartupPath + "\\test.wav";
                    p.Load();
                    p.Play();
                }
                else
                {
                    NUM = num;
                    NUM1 = num1;
                    NUM2 = num2;
                    NUM4 = num4;
                    NUM5 = num5;
                    NUM6 = num6;
                }
            }
            else if (Session.CurrentOrgType == 0)
            {
               
                //实华黄岛
                string strSql = "select t.PLAN_NO,t.TRUCK_NO,ORDER_TIME,decode(t.IF_END, '0','在场','1','离场') IF_END,decode(t.ORGCODE, '01','实华黄岛','02','实华董家口','03','摩科瑞','21','红星库区','22','天安','23','丽星','24','益佳','25','中油','11','平安停车场1','12','平安停车场2','13','平安停车场3','15','安顺停车场1','16','安顺停车场2','23','金赛物流停车场') ORGNAME ,t.IN_PARK_TIME AS IN_DATE  from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p  where    t.IF_END='0' and  t.ORGCODE = '" + Session.CurrentOrgCode + "' and t.plan_no=p.Plan_No and p.depot_code='01'   ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL = DataAccess.ExecuteDataTable(strSql);
                if (dtCYJL != null && dtCYJL.Rows.Count > 0)
                {
                    dtCYJL.Columns.Add("DRIVER_TEL", typeof(string));
                    for (int i = 0; i < dtCYJL.Rows.Count; i++)
                    {
                        string TRUCK_NO = dtCYJL.Rows[i]["TRUCK_NO"].ToString();
                        string PLAN_NO = dtCYJL.Rows[i]["PLAN_NO"].ToString();
                        string strSqlTel = "select d.phone as DRIVER_TEL from wlw_dbc_driver d where d.id in (select b.driver_id from wlw_dbc_oil_bill b where b.plan_no= '" + PLAN_NO + "' and head_car_id in (select i.id from wlw_dbc_oilcar_info i where i.car_no= '" + TRUCK_NO + "'))";
                        DataTable dtTel = DataAccess.ExecuteDataTable(strSqlTel);
                        if (dtTel != null && dtTel.Rows.Count > 0)
                        {
                            string DRIVER_TEL = dtTel.Rows[0]["DRIVER_TEL"].ToString();
                            dtCYJL.Rows[i]["DRIVER_TEL"] = DRIVER_TEL;
                        }
                    }
                   
                }
                this.cdgvGZJL.AutoGenerateColumns = false;
                this.cdgvGZJL.DataSource = dtCYJL;
                //进行统计
                string strSqlNum = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.IF_END='0' and  t.ORGCODE = '" + Session.CurrentOrgCode + "' and t.plan_no=p.Plan_No and p.depot_code='01'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJLNum = DataAccess.ExecuteDataTable(strSqlNum);
                string num = dtCYJLNum.Rows[0]["NUM"].ToString();
                this.label2.Text = num;
                //丽星
                string strSql1 = "select t.PLAN_NO,t.TRUCK_NO,ORDER_TIME,decode(t.IF_END, '0','在场','1','离场') IF_END,decode(t.ORGCODE, '01','实华黄岛','02','实华董家口','03','摩科瑞','21','红星库区','22','天安','23','丽星','24','益佳','25','中油','11','平安停车场1','12','平安停车场2','13','平安停车场3','15','安顺停车场1','16','安顺停车场2','23','金赛物流停车场') ORGNAME,t.IN_PARK_TIME AS IN_DATE  from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p  where    t.IF_END='0' and  t.ORGCODE = '" + Session.CurrentOrgCode + "' and t.plan_no=p.Plan_No and p.depot_code='23'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL1 = DataAccess.ExecuteDataTable(strSql1);
                if (dtCYJL1 != null && dtCYJL1.Rows.Count > 0)
                {
                    dtCYJL1.Columns.Add("DRIVER_TEL", typeof(string));
                    for (int i = 0; i < dtCYJL1.Rows.Count; i++)
                    {
                        string TRUCK_NO = dtCYJL1.Rows[i]["TRUCK_NO"].ToString();
                        string PLAN_NO = dtCYJL1.Rows[i]["PLAN_NO"].ToString();
                        string strSqlTel = "select d.phone as DRIVER_TEL from wlw_dbc_driver d where d.id in (select b.driver_id from wlw_dbc_oil_bill b where b.plan_no= '" + PLAN_NO + "' and head_car_id in (select i.id from wlw_dbc_oilcar_info i where i.car_no= '" + TRUCK_NO + "'))";
                        DataTable dtTel = DataAccess.ExecuteDataTable(strSqlTel);
                        if (dtTel != null && dtTel.Rows.Count > 0)
                        {
                            string DRIVER_TEL = dtTel.Rows[0]["DRIVER_TEL"].ToString();
                            dtCYJL1.Rows[i]["DRIVER_TEL"] = DRIVER_TEL;
                        }
                    }
                   
                }
                this.cDataGridView1.AutoGenerateColumns = false;
                this.cDataGridView1.DataSource = dtCYJL1;
                //进行统计
                string strSql1Num = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.IF_END='0' and t.ORGCODE = '" + Session.CurrentOrgCode + "' and t.plan_no=p.Plan_No and p.depot_code='23'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL1Num = DataAccess.ExecuteDataTable(strSql1Num);
                string num1 = dtCYJL1Num.Rows[0]["NUM"].ToString();
                this.label10.Text = num1;
                //天安
                string strSql2 = "select t.PLAN_NO,t.TRUCK_NO,ORDER_TIME,decode(t.IF_END, '0','在场','1','离场') IF_END,decode(t.ORGCODE, '01','实华黄岛','02','实华董家口','03','摩科瑞','21','红星库区','22','天安','23','丽星','24','益佳','25','中油','11','平安停车场1','12','平安停车场2','13','平安停车场3','15','安顺停车场1','16','安顺停车场2','23','金赛物流停车场') ORGNAME ,t.IN_PARK_TIME AS IN_DATE  from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p  where    t.IF_END='0' and  t.ORGCODE = '" + Session.CurrentOrgCode + "' and t.plan_no=p.Plan_No and p.depot_code='22'   ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL2 = DataAccess.ExecuteDataTable(strSql2);
                if (dtCYJL2 != null && dtCYJL2.Rows.Count > 0)
                {
                    dtCYJL2.Columns.Add("DRIVER_TEL", typeof(string));
                    for (int i = 0; i < dtCYJL2.Rows.Count; i++)
                    {
                        string TRUCK_NO = dtCYJL2.Rows[i]["TRUCK_NO"].ToString();
                        string PLAN_NO = dtCYJL2.Rows[i]["PLAN_NO"].ToString();
                        string strSqlTel = "select d.phone as DRIVER_TEL from wlw_dbc_driver d where d.id in (select b.driver_id from wlw_dbc_oil_bill b where b.plan_no= '" + PLAN_NO + "' and head_car_id in (select i.id from wlw_dbc_oilcar_info i where i.car_no= '" + TRUCK_NO + "'))";
                        DataTable dtTel = DataAccess.ExecuteDataTable(strSqlTel);
                        if (dtTel != null && dtTel.Rows.Count > 0)
                        {
                            string DRIVER_TEL = dtTel.Rows[0]["DRIVER_TEL"].ToString();
                            dtCYJL2.Rows[i]["DRIVER_TEL"] = DRIVER_TEL;
                        }
                    }
                    
                }
                this.cDataGridView2.AutoGenerateColumns = false;
                this.cDataGridView2.DataSource = dtCYJL2;
                //进行统计
                string strSql2Num = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where  t.IF_END='0'  and t.ORGCODE = '" + Session.CurrentOrgCode + "' and t.plan_no=p.Plan_No and p.depot_code='22'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL2Num = DataAccess.ExecuteDataTable(strSql2Num);
                string num2 = dtCYJL2Num.Rows[0]["NUM"].ToString();
                this.label12.Text = num2;
                //益佳
                string strSql3 = "select t.PLAN_NO,t.TRUCK_NO,ORDER_TIME,decode(t.IF_END, '0','在场','1','离场') IF_END,decode(t.ORGCODE, '01','实华黄岛','02','实华董家口','03','摩科瑞','21','红星库区','22','天安','23','丽星','24','益佳','25','中油','11','平安停车场1','12','平安停车场2','13','平安停车场3','15','安顺停车场1','16','安顺停车场2','23','金赛物流停车场') ORGNAME ,t.IN_PARK_TIME AS IN_DATE  from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p  where    t.IF_END='0' and  t.ORGCODE = '" + Session.CurrentOrgCode + "' and t.plan_no=p.Plan_No and p.depot_code='24'   ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL3 = DataAccess.ExecuteDataTable(strSql3);
                if (dtCYJL3 != null && dtCYJL3.Rows.Count > 0)
                {
                    dtCYJL3.Columns.Add("DRIVER_TEL", typeof(string));
                    for (int i = 0; i < dtCYJL3.Rows.Count; i++)
                    {
                        string TRUCK_NO = dtCYJL3.Rows[i]["TRUCK_NO"].ToString();
                        string PLAN_NO = dtCYJL3.Rows[i]["PLAN_NO"].ToString();
                        string strSqlTel = "select d.phone as DRIVER_TEL from wlw_dbc_driver d where d.id in (select b.driver_id from wlw_dbc_oil_bill b where b.plan_no= '" + PLAN_NO + "' and head_car_id in (select i.id from wlw_dbc_oilcar_info i where i.car_no= '" + TRUCK_NO + "'))";
                        DataTable dtTel = DataAccess.ExecuteDataTable(strSqlTel);
                        if (dtTel != null && dtTel.Rows.Count > 0)
                        {
                            string DRIVER_TEL = dtTel.Rows[0]["DRIVER_TEL"].ToString();
                            dtCYJL3.Rows[i]["DRIVER_TEL"] = DRIVER_TEL;
                        }
                    }
                   
                }
                this.cDataGridView3.AutoGenerateColumns = false;
                this.cDataGridView3.DataSource = dtCYJL3;
                //进行统计
                string strSql4Num = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.IF_END='0'  and t.ORGCODE = '" + Session.CurrentOrgCode + "' and t.plan_no=p.Plan_No and p.depot_code='24'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL4Num = DataAccess.ExecuteDataTable(strSql4Num);
                string num4 = dtCYJL4Num.Rows[0]["NUM"].ToString();
                this.label14.Text = num4;
                //中油
                string strSql4 = "select t.PLAN_NO,t.TRUCK_NO,ORDER_TIME,decode(t.IF_END, '0','在场','1','离场') IF_END,decode(t.ORGCODE, '01','实华黄岛','02','实华董家口','03','摩科瑞','21','红星库区','22','天安','23','丽星','24','益佳','25','中油','11','平安停车场1','12','平安停车场2','13','平安停车场3','15','安顺停车场1','16','安顺停车场2','23','金赛物流停车场') ORGNAME ,t.IN_PARK_TIME AS IN_DATE  from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p  where    t.IF_END='0' and  t.ORGCODE = '" + Session.CurrentOrgCode + "' and t.plan_no=p.Plan_No and p.depot_code='25'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL4 = DataAccess.ExecuteDataTable(strSql4);
                if (dtCYJL4 != null && dtCYJL4.Rows.Count > 0)
                {
                    dtCYJL4.Columns.Add("DRIVER_TEL", typeof(string));
                    for (int i = 0; i < dtCYJL4.Rows.Count; i++)
                    {
                        string TRUCK_NO = dtCYJL4.Rows[i]["TRUCK_NO"].ToString();
                        string PLAN_NO = dtCYJL4.Rows[i]["PLAN_NO"].ToString();
                        string strSqlTel = "select d.phone as DRIVER_TEL from wlw_dbc_driver d where d.id in (select b.driver_id from wlw_dbc_oil_bill b where b.plan_no= '" + PLAN_NO + "' and head_car_id in (select i.id from wlw_dbc_oilcar_info i where i.car_no= '" + TRUCK_NO + "'))";
                        DataTable dtTel = DataAccess.ExecuteDataTable(strSqlTel);
                        if (dtTel != null && dtTel.Rows.Count > 0)
                        {
                            string DRIVER_TEL = dtTel.Rows[0]["DRIVER_TEL"].ToString();
                            dtCYJL4.Rows[i]["DRIVER_TEL"] = DRIVER_TEL;
                        }
                    }
                    
                }
                this.cDataGridView4.AutoGenerateColumns = false;
                this.cDataGridView4.DataSource = dtCYJL4;
                //进行统计
                string strSql5Num = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.IF_END='0' and t.ORGCODE = '" + Session.CurrentOrgCode + "' and t.plan_no=p.Plan_No and p.depot_code='25'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL5Num = DataAccess.ExecuteDataTable(strSql5Num);
                string num5 = dtCYJL5Num.Rows[0]["NUM"].ToString();
                this.label16.Text = num5;

                //红星
                string strSql5 = "select t.PLAN_NO,t.TRUCK_NO,ORDER_TIME,decode(t.IF_END, '0','在场','1','离场') IF_END,decode(t.ORGCODE, '01','实华黄岛','02','实华董家口','03','摩科瑞','21','红星库区','22','天安','23','丽星','24','益佳','25','中油','11','平安停车场1','12','平安停车场2','13','平安停车场3','15','安顺停车场1','16','安顺停车场2','23','金赛物流停车场') ORGNAME ,t.IN_PARK_TIME AS IN_DATE  from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p  where    t.IF_END='0' and  t.ORGCODE = '" + Session.CurrentOrgCode + "' and t.plan_no=p.Plan_No and p.depot_code='21'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL5 = DataAccess.ExecuteDataTable(strSql5);
                if (dtCYJL5 != null && dtCYJL5.Rows.Count > 0)
                {
                    dtCYJL5.Columns.Add("DRIVER_TEL", typeof(string));
                    for (int i = 0; i < dtCYJL5.Rows.Count; i++)
                    {
                        string TRUCK_NO = dtCYJL5.Rows[i]["TRUCK_NO"].ToString();
                        string PLAN_NO = dtCYJL5.Rows[i]["PLAN_NO"].ToString();
                        string strSqlTel = "select d.phone as DRIVER_TEL from wlw_dbc_driver d where d.id in (select b.driver_id from wlw_dbc_oil_bill b where b.plan_no= '" + PLAN_NO + "' and head_car_id in (select i.id from wlw_dbc_oilcar_info i where i.car_no= '" + TRUCK_NO + "'))";
                        DataTable dtTel = DataAccess.ExecuteDataTable(strSqlTel);
                        if (dtTel != null && dtTel.Rows.Count > 0)
                        {
                            string DRIVER_TEL = dtTel.Rows[0]["DRIVER_TEL"].ToString();
                            dtCYJL5.Rows[i]["DRIVER_TEL"] = DRIVER_TEL;
                        }
                    }
                   
                }
                this.cDataGridView5.AutoGenerateColumns = false;
                this.cDataGridView5.DataSource = dtCYJL5;
                //进行统计
                string strSql6Num = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.IF_END='0' and t.ORGCODE = '" + Session.CurrentOrgCode + "' and t.plan_no=p.Plan_No and p.depot_code='21'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL6Num = DataAccess.ExecuteDataTable(strSql6Num);
                string num6 = dtCYJL6Num.Rows[0]["NUM"].ToString();
                this.label18.Text = num6;
                int num_int = 0;
                int num1_int = 0;
                int num2_int = 0;
                int num4_int = 0;
                int num5_int = 0;
                int num6_int = 0;

                int NUM_INT = 0;
                int NUM1_INT = 0;
                int NUM2_INT = 0;
                int NUM4_INT = 0;
                int NUM5_INT = 0;
                int NUM6_INT = 0;
                try
                {
                    num_int = int.Parse(num);
                    num1_int = int.Parse(num1);
                    num2_int = int.Parse(num2);
                    num4_int = int.Parse(num4);
                    num5_int = int.Parse(num5);
                    num6_int = int.Parse(num6);

                    NUM_INT = int.Parse(NUM);
                    NUM1_INT = int.Parse(NUM1);
                    NUM2_INT = int.Parse(NUM2);
                    NUM4_INT = int.Parse(NUM4);
                    NUM5_INT = int.Parse(NUM5);
                    NUM6_INT = int.Parse(NUM6);
                }
                catch (Exception e)
                {
                    throw e;
                }
                if (num_int > NUM_INT || num1_int > NUM1_INT || num2_int > NUM2_INT || num4_int > NUM4_INT || num5_int > NUM5_INT || num6_int > NUM6_INT)
                {
                    NUM = num;
                    NUM1 = num1;
                    NUM2 = num2;
                    NUM4 = num4;
                    NUM5 = num5;
                    NUM6 = num6;
                    SoundPlayer p = new SoundPlayer();
                    p.SoundLocation = Application.StartupPath + "\\test.wav";
                    p.Load();
                    p.Play();
                }
                else
                {
                    NUM = num;
                    NUM1 = num1;
                    NUM2 = num2;
                    NUM4 = num4;
                    NUM5 = num5;
                    NUM6 = num6;
                }

            }
            else if (Session.CurrentOrgType == 1)
            {
                //实华黄岛
                string strSql = "select t.PLAN_NO,t.TRUCK_NO,ORDER_TIME,decode(t.IF_END, '0','在场','1','离场') IF_END,decode(t.ORGCODE, '01','实华黄岛','02','实华董家口','03','摩科瑞','21','红星库区','22','天安','23','丽星','24','益佳','25','中油','11','平安停车场1','12','平安停车场2','13','平安停车场3','15','安顺停车场1','16','安顺停车场2','23','金赛物流停车场') ORGNAME ,t.IN_PARK_TIME AS IN_DATE  from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p  where    t.IF_END='0' and  t.ORGCODE = '" + Session.CurrentOrgCode + "' and t.plan_no=p.Plan_No and p.depot_code='01'   ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL = DataAccess.ExecuteDataTable(strSql);
                if (dtCYJL != null && dtCYJL.Rows.Count > 0)
                {
                    dtCYJL.Columns.Add("DRIVER_TEL", typeof(string));
                    for (int i = 0; i < dtCYJL.Rows.Count; i++)
                    {
                        string TRUCK_NO = dtCYJL.Rows[i]["TRUCK_NO"].ToString();
                        string PLAN_NO = dtCYJL.Rows[i]["PLAN_NO"].ToString();
                        string strSqlTel = "select d.phone as DRIVER_TEL from wlw_dbc_driver d where d.id in (select b.driver_id from wlw_dbc_oil_bill b where b.plan_no= '" + PLAN_NO + "' and head_car_id in (select i.id from wlw_dbc_oilcar_info i where i.car_no= '" + TRUCK_NO + "'))";
                        DataTable dtTel = DataAccess.ExecuteDataTable(strSqlTel);
                        if (dtTel != null && dtTel.Rows.Count > 0)
                        {
                            string DRIVER_TEL = dtTel.Rows[0]["DRIVER_TEL"].ToString();
                            dtCYJL.Rows[i]["DRIVER_TEL"] = DRIVER_TEL;
                        }
                    }
                   
                }
                this.cdgvGZJL.AutoGenerateColumns = false;
                this.cdgvGZJL.DataSource = dtCYJL;
                //进行统计
                string strSqlNum = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.IF_END='0' and  t.ORGCODE = '" + Session.CurrentOrgCode + "' and t.plan_no=p.Plan_No and p.depot_code='01'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJLNum = DataAccess.ExecuteDataTable(strSqlNum);
                string num = dtCYJLNum.Rows[0]["NUM"].ToString();
                this.label2.Text = num;
                //丽星
                string strSql1 = "select t.PLAN_NO,t.TRUCK_NO,ORDER_TIME,decode(t.IF_END, '0','在场','1','离场') IF_END,decode(t.ORGCODE, '01','实华黄岛','02','实华董家口','03','摩科瑞','21','红星库区','22','天安','23','丽星','24','益佳','25','中油','11','平安停车场1','12','平安停车场2','13','平安停车场3','15','安顺停车场1','16','安顺停车场2','23','金赛物流停车场') ORGNAME ,t.IN_PARK_TIME AS IN_DATE  from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p  where    t.IF_END='0' and  t.ORGCODE = '" + Session.CurrentOrgCode + "' and t.plan_no=p.Plan_No and p.depot_code='23'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL1 = DataAccess.ExecuteDataTable(strSql1);
                if (dtCYJL1 != null && dtCYJL1.Rows.Count > 0)
                {
                    dtCYJL1.Columns.Add("DRIVER_TEL", typeof(string));
                    for (int i = 0; i < dtCYJL1.Rows.Count; i++)
                    {
                        string TRUCK_NO = dtCYJL1.Rows[i]["TRUCK_NO"].ToString();
                        string PLAN_NO = dtCYJL1.Rows[i]["PLAN_NO"].ToString();
                        string strSqlTel = "select d.phone as DRIVER_TEL from wlw_dbc_driver d where d.id in (select b.driver_id from wlw_dbc_oil_bill b where b.plan_no= '" + PLAN_NO + "' and head_car_id in (select i.id from wlw_dbc_oilcar_info i where i.car_no= '" + TRUCK_NO + "'))";
                        DataTable dtTel = DataAccess.ExecuteDataTable(strSqlTel);
                        if (dtTel != null && dtTel.Rows.Count > 0)
                        {
                            string DRIVER_TEL = dtTel.Rows[0]["DRIVER_TEL"].ToString();
                            dtCYJL1.Rows[i]["DRIVER_TEL"] = DRIVER_TEL;
                        }
                    }
                   
                }
                this.cDataGridView1.AutoGenerateColumns = false;
                this.cDataGridView1.DataSource = dtCYJL1;
                //进行统计
                string strSql1Num = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.IF_END='0' and t.ORGCODE = '" + Session.CurrentOrgCode + "' and t.plan_no=p.Plan_No and p.depot_code='23'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL1Num = DataAccess.ExecuteDataTable(strSql1Num);
                string num1 = dtCYJL1Num.Rows[0]["NUM"].ToString();
                this.label10.Text = num1;
                //天安
                string strSql2 = "select t.PLAN_NO,t.TRUCK_NO,ORDER_TIME,decode(t.IF_END, '0','在场','1','离场') IF_END,decode(t.ORGCODE, '01','实华黄岛','02','实华董家口','03','摩科瑞','21','红星库区','22','天安','23','丽星','24','益佳','25','中油','11','平安停车场1','12','平安停车场2','13','平安停车场3','15','安顺停车场1','16','安顺停车场2','23','金赛物流停车场') ORGNAME ,t.IN_PARK_TIME AS IN_DATE  from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p  where    t.IF_END='0' and  t.ORGCODE = '" + Session.CurrentOrgCode + "' and t.plan_no=p.Plan_No and p.depot_code='22'   ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL2 = DataAccess.ExecuteDataTable(strSql2);
                if (dtCYJL2 != null && dtCYJL2.Rows.Count > 0)
                {
                    dtCYJL2.Columns.Add("DRIVER_TEL", typeof(string));
                    for (int i = 0; i < dtCYJL2.Rows.Count; i++)
                    {
                        string TRUCK_NO = dtCYJL2.Rows[i]["TRUCK_NO"].ToString();
                        string PLAN_NO = dtCYJL2.Rows[i]["PLAN_NO"].ToString();
                        string strSqlTel = "select d.phone as DRIVER_TEL from wlw_dbc_driver d where d.id in (select b.driver_id from wlw_dbc_oil_bill b where b.plan_no= '" + PLAN_NO + "' and head_car_id in (select i.id from wlw_dbc_oilcar_info i where i.car_no= '" + TRUCK_NO + "'))";
                        DataTable dtTel = DataAccess.ExecuteDataTable(strSqlTel);
                        if (dtTel != null && dtTel.Rows.Count > 0)
                        {
                            string DRIVER_TEL = dtTel.Rows[0]["DRIVER_TEL"].ToString();
                            dtCYJL2.Rows[i]["DRIVER_TEL"] = DRIVER_TEL;
                        }
                    }
                    
                }
                this.cDataGridView2.AutoGenerateColumns = false;
                this.cDataGridView2.DataSource = dtCYJL2;
                //进行统计
                string strSql2Num = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where  t.IF_END='0'  and t.ORGCODE = '" + Session.CurrentOrgCode + "' and t.plan_no=p.Plan_No and p.depot_code='22'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL2Num = DataAccess.ExecuteDataTable(strSql2Num);
                string num2 = dtCYJL2Num.Rows[0]["NUM"].ToString();
                this.label12.Text = num2;
                //益佳
                string strSql3 = "select t.PLAN_NO,t.TRUCK_NO,ORDER_TIME,decode(t.IF_END, '0','在场','1','离场') IF_END,decode(t.ORGCODE, '01','实华黄岛','02','实华董家口','03','摩科瑞','21','红星库区','22','天安','23','丽星','24','益佳','25','中油','11','平安停车场1','12','平安停车场2','13','平安停车场3','15','安顺停车场1','16','安顺停车场2','23','金赛物流停车场') ORGNAME ,t.IN_PARK_TIME AS IN_DATE  from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p  where    t.IF_END='0' and  t.ORGCODE = '" + Session.CurrentOrgCode + "' and t.plan_no=p.Plan_No and p.depot_code='24'   ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL3 = DataAccess.ExecuteDataTable(strSql3);
                if (dtCYJL3 != null && dtCYJL3.Rows.Count > 0)
                {
                    dtCYJL3.Columns.Add("DRIVER_TEL", typeof(string));
                    for (int i = 0; i < dtCYJL3.Rows.Count; i++)
                    {
                        string TRUCK_NO = dtCYJL3.Rows[i]["TRUCK_NO"].ToString();
                        string PLAN_NO = dtCYJL3.Rows[i]["PLAN_NO"].ToString();
                        string strSqlTel = "select d.phone as DRIVER_TEL from wlw_dbc_driver d where d.id in (select b.driver_id from wlw_dbc_oil_bill b where b.plan_no= '" + PLAN_NO + "' and head_car_id in (select i.id from wlw_dbc_oilcar_info i where i.car_no= '" + TRUCK_NO + "'))";
                        DataTable dtTel = DataAccess.ExecuteDataTable(strSqlTel);
                        if (dtTel != null && dtTel.Rows.Count > 0)
                        {
                            string DRIVER_TEL = dtTel.Rows[0]["DRIVER_TEL"].ToString();
                            dtCYJL3.Rows[i]["DRIVER_TEL"] = DRIVER_TEL;
                        }
                    }
                    
                }
                this.cDataGridView3.AutoGenerateColumns = false;
                this.cDataGridView3.DataSource = dtCYJL3;
                //进行统计
                string strSql4Num = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.IF_END='0'  and t.ORGCODE = '" + Session.CurrentOrgCode + "' and t.plan_no=p.Plan_No and p.depot_code='24'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL4Num = DataAccess.ExecuteDataTable(strSql4Num);
                string num4 = dtCYJL4Num.Rows[0]["NUM"].ToString();
                this.label14.Text = num4;
                //中油
                string strSql4 = "select t.PLAN_NO,t.TRUCK_NO,ORDER_TIME,decode(t.IF_END, '0','在场','1','离场') IF_END,decode(t.ORGCODE, '01','实华黄岛','02','实华董家口','03','摩科瑞','21','红星库区','22','天安','23','丽星','24','益佳','25','中油','11','平安停车场1','12','平安停车场2','13','平安停车场3','15','安顺停车场1','16','安顺停车场2','23','金赛物流停车场') ORGNAME ,t.IN_PARK_TIME AS IN_DATE  from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p  where    t.IF_END='0' and  t.ORGCODE = '" + Session.CurrentOrgCode + "' and t.plan_no=p.Plan_No and p.depot_code='25'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL4 = DataAccess.ExecuteDataTable(strSql4);
                if (dtCYJL4 != null && dtCYJL4.Rows.Count > 0)
                {
                    dtCYJL4.Columns.Add("DRIVER_TEL", typeof(string));
                    for (int i = 0; i < dtCYJL4.Rows.Count; i++)
                    {
                        string TRUCK_NO = dtCYJL4.Rows[i]["TRUCK_NO"].ToString();
                        string PLAN_NO = dtCYJL4.Rows[i]["PLAN_NO"].ToString();
                        string strSqlTel = "select d.phone as DRIVER_TEL from wlw_dbc_driver d where d.id in (select b.driver_id from wlw_dbc_oil_bill b where b.plan_no= '" + PLAN_NO + "' and head_car_id in (select i.id from wlw_dbc_oilcar_info i where i.car_no= '" + TRUCK_NO + "'))";
                        DataTable dtTel = DataAccess.ExecuteDataTable(strSqlTel);
                        if (dtTel != null && dtTel.Rows.Count > 0)
                        {
                            string DRIVER_TEL = dtTel.Rows[0]["DRIVER_TEL"].ToString();
                            dtCYJL4.Rows[i]["DRIVER_TEL"] = DRIVER_TEL;
                        }
                    }
                    
                }
                this.cDataGridView4.AutoGenerateColumns = false;
                this.cDataGridView4.DataSource = dtCYJL4;
                //进行统计
                string strSql5Num = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.IF_END='0' and t.ORGCODE = '" + Session.CurrentOrgCode + "' and t.plan_no=p.Plan_No and p.depot_code='25'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL5Num = DataAccess.ExecuteDataTable(strSql5Num);
                string num5 = dtCYJL5Num.Rows[0]["NUM"].ToString();
                this.label16.Text = num5;

                //红星
                string strSql5 = "select t.PLAN_NO,t.TRUCK_NO,ORDER_TIME,decode(t.IF_END, '0','在场','1','离场') IF_END,decode(t.ORGCODE, '01','实华黄岛','02','实华董家口','03','摩科瑞','21','红星库区','22','天安','23','丽星','24','益佳','25','中油','11','平安停车场1','12','平安停车场2','13','平安停车场3','15','安顺停车场1','16','安顺停车场2','23','金赛物流停车场') ORGNAME ,t.IN_PARK_TIME AS IN_DATE  from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p  where    t.IF_END='0' and  t.ORGCODE = '" + Session.CurrentOrgCode + "' and t.plan_no=p.Plan_No and p.depot_code='21'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL5 = DataAccess.ExecuteDataTable(strSql5);
                if (dtCYJL5 != null && dtCYJL5.Rows.Count > 0)
                {
                    dtCYJL5.Columns.Add("DRIVER_TEL", typeof(string));
                    for (int i = 0; i < dtCYJL5.Rows.Count; i++)
                    {
                        string TRUCK_NO = dtCYJL5.Rows[i]["TRUCK_NO"].ToString();
                        string PLAN_NO = dtCYJL5.Rows[i]["PLAN_NO"].ToString();
                        string strSqlTel = "select d.phone as DRIVER_TEL from wlw_dbc_driver d where d.id in (select b.driver_id from wlw_dbc_oil_bill b where b.plan_no= '" + PLAN_NO + "' and head_car_id in (select i.id from wlw_dbc_oilcar_info i where i.car_no= '" + TRUCK_NO + "'))";
                        DataTable dtTel = DataAccess.ExecuteDataTable(strSqlTel);
                        if (dtTel != null && dtTel.Rows.Count > 0)
                        {
                            string DRIVER_TEL = dtTel.Rows[0]["DRIVER_TEL"].ToString();
                            dtCYJL5.Rows[i]["DRIVER_TEL"] = DRIVER_TEL;
                        }
                    }
                    
                }
                this.cDataGridView5.AutoGenerateColumns = false;
                this.cDataGridView5.DataSource = dtCYJL5;
                //进行统计
                string strSql6Num = "select count(*) as NUM from TRUCK_IN_ORDER_TNO t, wlw_dbc_oil_plan p where t.IF_END='0' and t.ORGCODE = '" + Session.CurrentOrgCode + "' and t.plan_no=p.Plan_No and p.depot_code='21'  ORDER BY t.ORDER_TIME ASC";
                DataTable dtCYJL6Num = DataAccess.ExecuteDataTable(strSql6Num);
                string num6 = dtCYJL6Num.Rows[0]["NUM"].ToString();
                this.label18.Text = num6;
                int num_int = 0;
                int num1_int = 0;
                int num2_int = 0;
                int num4_int = 0;
                int num5_int = 0;
                int num6_int = 0;

                int NUM_INT = 0;
                int NUM1_INT = 0;
                int NUM2_INT = 0;
                int NUM4_INT = 0;
                int NUM5_INT = 0;
                int NUM6_INT = 0;
                try
                {
                    num_int = int.Parse(num);
                    num1_int = int.Parse(num1);
                    num2_int = int.Parse(num2);
                    num4_int = int.Parse(num4);
                    num5_int = int.Parse(num5);
                    num6_int = int.Parse(num6);

                    NUM_INT = int.Parse(NUM);
                    NUM1_INT = int.Parse(NUM1);
                    NUM2_INT = int.Parse(NUM2);
                    NUM4_INT = int.Parse(NUM4);
                    NUM5_INT = int.Parse(NUM5);
                    NUM6_INT = int.Parse(NUM6);
                }
                catch (Exception e)
                {
                    throw e;
                }
                if (num_int > NUM_INT || num1_int > NUM1_INT || num2_int > NUM2_INT || num4_int > NUM4_INT || num5_int > NUM5_INT || num6_int > NUM6_INT)
                {
                    NUM = num;
                    NUM1 = num1;
                    NUM2 = num2;
                    NUM4 = num4;
                    NUM5 = num5;
                    NUM6 = num6;
                    SoundPlayer p = new SoundPlayer();
                    p.SoundLocation = Application.StartupPath + "\\test.wav";
                    p.Load();
                    p.Play();
                }
                else
                {
                    NUM = num;
                    NUM1 = num1;
                    NUM2 = num2;
                    NUM4 = num4;
                    NUM5 = num5;
                    NUM6 = num6;
                }

            }
        }

        private void FczlModule_Load(object sender, EventArgs e)
        {
            Control.CheckForIllegalCrossThreadCalls = false;
            timer1.Enabled = true;
            //System.Timers.Timer t = new System.Timers.Timer(2000);   //实例化Timer类，设置间隔时间为10000毫秒；   
            //t.Elapsed += new System.Timers.ElapsedEventHandler(theout); //到达时间的时候执行事件；   
            //t.AutoReset = true;   //设置是执行一次（false）还是一直执行(true)；   
            //t.Enabled = true;     //是否执行System.Timers.Timer.Elapsed事件；   
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            OnLoadModule();
        }
        //public void theout(object source, System.Timers.ElapsedEventArgs e)
        //{
        //    OnLoadModule();
        //}  
    }
}
